4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Haejeong Kim <backto.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.
25 #include "mm_file_utils.h"
27 #ifdef __MMFILE_MEM_TRACE__
29 void *mmfile_malloc_debug(unsigned int size, const char *func, unsigned int line)
31 void *tmp = malloc(size);
34 memset(tmp, 0x00, size);
35 debug_msg(RELEASE, "## DEBUG ## %p = malloc (%d) by %s() %d\n", tmp, size, func, line);
41 void *mmfile_calloc_debug(unsigned int nmemb, unsigned int size, const char *func, unsigned int line)
43 void *tmp = calloc(nmemb, size);
46 debug_msg(RELEASE, "## DEBUG ## %p = calloc (%d, %d) by %s() %d\n", tmp, nmemb, size, func, line);
52 void mmfile_free_debug(void *ptr, const char *func, unsigned int line)
55 debug_msg(RELEASE, "## DEBUG ## free (%p) by %s() %d\n", ptr, func, line);
62 void *mmfile_realloc_debug(void *ptr, unsigned int size, const char *func, unsigned int line)
64 void *tmp = realloc(ptr, size);
67 debug_msg(RELEASE, "## DEBUG ## %p = realloc (%p, %d) by %s() %d\n", tmp, ptr, size, func, line);
73 void *mmfile_memset_debug(void *s, int c, unsigned int n, const char *func, unsigned int line)
75 debug_msg(RELEASE, "## DEBUG ## memset (%p, %d, %d) by %s() %d\n", s, c, n, func, line);
77 return memset(s, c, n);
81 void *mmfile_memcpy_debug(void *dest, const void *src, unsigned int n, const char *func, unsigned int line)
83 debug_msg(RELEASE, "## DEBUG ## memcpy (%p, %p, %d) by %s() %d\n", dest, src, n, func, line);
85 return memcpy(dest, src, n);
88 #else /* __MMFILE_MEM_TRACE__ : ------------------------------------------------------------------*/
91 void *mmfile_malloc(unsigned int size)
93 void *tmp = malloc(size);
95 memset(tmp, 0x00, size);
101 void *mmfile_calloc(unsigned int nmemb, unsigned int size)
103 void *tmp = calloc(nmemb, size);
108 void mmfile_free_r(void *ptr)
114 void *mmfile_realloc(void *ptr, unsigned int size)
116 return realloc(ptr, size);
120 void *mmfile_memset(void *s, int c, unsigned int n)
122 return memset(s, c, n);
126 void *mmfile_memcpy(void *dest, const void *src, unsigned int n)
128 return memcpy(dest, src, n);