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 fprintf (stderr, "## 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 fprintf (stderr, "## 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 fprintf (stderr, "## 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 fprintf (stderr, "## 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 fprintf (stderr, "## DEBUG ## memset (%p, %d, %d) by %s() %d\n", s, c, n, func, line);
76 return memset (s, c, n);
80 void *mmfile_memcpy_debug (void *dest, const void *src, unsigned int n, const char *func, unsigned int line)
82 fprintf (stderr, "## DEBUG ## memcpy (%p, %p, %d) by %s() %d\n", dest, src, n, func, line);
83 return memcpy (dest, src, n);
86 #else /* __MMFILE_MEM_TRACE__ : ------------------------------------------------------------------*/
89 void *mmfile_malloc (unsigned int size)
91 void *tmp = malloc (size);
94 memset (tmp, 0x00, size);
100 void *mmfile_calloc (unsigned int nmemb, unsigned int size)
102 void *tmp = calloc (nmemb, size);
107 void mmfile_free_r (void *ptr)
113 void *mmfile_realloc (void *ptr, unsigned int size)
115 return realloc (ptr, size);
119 void *mmfile_memset (void *s, int c, unsigned int n)
121 return memset (s, c, n);
125 void *mmfile_memcpy (void *dest, const void *src, unsigned int n)
127 return memcpy (dest, src, n);