00001 /* clib/include/malloc.h 00002 * 00003 * Memory allocation routines for ABLE applications. 00004 * 00005 * Copyright 2003 Simtec Electronics 00006 * 00007 * Permission is hereby granted, free of charge, to any person 00008 * obtaining a copy of this software and associated documentation 00009 * files (the "Software"), to deal in the Software without 00010 * restriction, including without limitation the rights to use, copy, 00011 * modify, merge, publish, distribute, sublicense, and/or sell copies 00012 * of the Software, and to permit persons to whom the Software is 00013 * furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be 00016 * included in all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00019 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00021 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 00022 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 00023 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 00024 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00025 * SOFTWARE. 00026 * 00027 */ 00028 00029 #ifndef _ABLE_CLIB_MALLOC_H 00030 #define _ABLE_CLIB_MALLOC_H 1 00031 00032 /* malloc requires the types */ 00033 #include <sys/types.h> 00034 00035 /* This is an internal configuration varaible for ABLE, defining this in an 00036 * application will cause it to fail to link. 00037 */ 00038 #ifndef CONFIG_DEBUG_MALLOC 00039 00049 extern void *calloc(size_t nmemb, size_t size); 00050 00058 extern void *malloc(size_t size); 00059 00082 extern void *realloc(void *ptr, size_t size); 00083 00091 extern void free(void *ptr); 00092 00093 #else /* #ifndef CONFIG_DEBUG_MALLOC */ 00094 00095 extern void *dbg_calloc(size_t nmemb, size_t size, const char *from, int lno); 00096 extern void *dbg_malloc(size_t size, const char *from, int lno); 00097 extern void *dbg_realloc(void * ptr,size_t size, const char *from, int lno); 00098 extern void dbg_free(void * ptr, const char *from, int lno); 00099 00100 #define calloc(x,y) dbg_calloc(x,y,__FILE__,__LINE__) 00101 #define realloc(x,y) dbg_realloc(x,y,__FILE__,__LINE__) 00102 #define malloc(x) dbg_malloc(x, __FILE__, __LINE__) 00103 #define free(x) dbg_free(x, __FILE__, __LINE__) 00104 00105 #endif /* #ifndef CONFIG_DEBUG_MALLOC */ 00106 00107 00108 #endif /* _ABLE_CLIB_MALLOC_H */