4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: YoungHun Kim <yh8004.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MM_UTIL_PRIVATE_H__
23 #define __MM_UTIL_PRIVATE_H__
28 #include "mm_util_debug.h"
29 #include "mm_util_type.h"
35 /* for memory management */
36 #define MMUTIL_SAFE_FREE(x) { if (x) { free(x); x = NULL; } }
37 #define MMUTIL_SAFE_G_FREE(x) { if (x) { g_free(x); x = NULL; } }
38 #define MMUTIL_SAFE_STRCPY(dst, src, n) g_strlcpy(dst, src, n)
39 #define MMUTIL_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
41 #define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
44 #define MM_UTIL_ROUND_UP_2(num) (((num)+1)&~1)
45 #define MM_UTIL_ROUND_UP_4(num) (((num)+3)&~3)
46 #define MM_UTIL_ROUND_UP_8(num) (((num)+7)&~7)
47 #define MM_UTIL_ROUND_UP_16(num) (((num)+15)&~15)
48 #define MM_UTIL_ROUND_DOWN_2(num) ((num)&(~1))
49 #define MM_UTIL_ROUND_DOWN_4(num) ((num)&(~3))
50 #define MM_UTIL_ROUND_DOWN_16(num) ((num)&(~15))
52 int mm_util_safe_fopen(const char *path, const char *mode, FILE **fp);
53 void mm_util_safe_fclose(FILE *fp);
59 #endif /*__MM_UTIL_PRIVATE_H__*/