00001 /* 00002 * @(#)debug_malloc.h 1.8 10/03/23 00003 * 00004 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * 00009 * -Redistribution of source code must retain the above copyright notice, this 00010 * list of conditions and the following disclaimer. 00011 * 00012 * -Redistribution in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 00016 * Neither the name of Oracle or the names of contributors may 00017 * be used to endorse or promote products derived from this software without 00018 * specific prior written permission. 00019 * 00020 * This software is provided "AS IS," without a warranty of any kind. ALL 00021 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING 00022 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00023 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") 00024 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE 00025 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS 00026 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST 00027 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, 00028 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY 00029 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 00030 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00031 * 00032 * You acknowledge that this software is not designed, licensed or intended 00033 * for use in the design, construction, operation or maintenance of any 00034 * nuclear facility. 00035 */ 00036 00037 /* *********************************************************************** 00038 * 00039 * The source file debug_malloc.c should be included with your sources. 00040 * 00041 * The object file debug_malloc.o should be included with your object files. 00042 * 00043 * WARNING: Any memory allocattion from things like memalign(), valloc(), 00044 * or any memory not coming from these macros (malloc, realloc, 00045 * calloc, and strdup) will fail miserably. 00046 * 00047 * *********************************************************************** 00048 */ 00049 00050 #ifndef _DEBUG_MALLOC_H 00051 #define _DEBUG_MALLOC_H 00052 00053 #ifdef DEBUG 00054 00055 #include <stdlib.h> 00056 #include <string.h> 00057 00058 /* The real functions behind the macro curtains. */ 00059 00060 void *debug_malloc(size_t, const char *, int); 00061 void *debug_realloc(void *, size_t, const char *, int); 00062 void *debug_calloc(size_t, size_t, const char *, int); 00063 char *debug_strdup(const char *, const char *, int); 00064 void debug_free(void *, const char *, int); 00065 00066 #endif 00067 00068 void debug_malloc_verify(const char*, int); 00069 #undef malloc_verify 00070 #define malloc_verify() debug_malloc_verify(__FILE__, __LINE__) 00071 00072 void debug_malloc_police(const char*, int); 00073 #undef malloc_police 00074 #define malloc_police() debug_malloc_police(__FILE__, __LINE__) 00075 00076 #endif
1.6.1