Update Iot.js
[platform/upstream/iotjs.git] / src / iotjs_util.h
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef IOTJS_UTIL_H
17 #define IOTJS_UTIL_H
18
19
20 #include "iotjs_string.h"
21
22
23 // Return value should be released with iotjs_string_destroy()
24 iotjs_string_t iotjs_file_read(const char* path);
25
26 char* iotjs_buffer_allocate(unsigned size);
27 char* iotjs_buffer_reallocate(char* buffer, unsigned size);
28 void iotjs_buffer_release(char* buff);
29
30 #define IOTJS_ALLOC(type) /* Allocate (type)-sized, (type*)-typed memory */ \
31   (type*)iotjs_buffer_allocate(sizeof(type))
32
33 #define IOTJS_RELEASE(ptr) /* Release memory allocated by IOTJS_ALLOC() */ \
34   iotjs_buffer_release((char*)ptr)
35
36
37 #endif /* IOTJS_UTIL_H */