/* $Id: w_malloc.h,v 2.8 2010/04/18 15:24:47 smissaert Exp $ */ /* * Copyright (c) 2006-2010 Ludo Smissaert <ludo@ludikidee.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the original author nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* this file is part of libwmalloc */ #ifndef __W_MALLOC_H__ #define __W_MALLOC_H__ void *wrapper_malloc(size_t, const char *); void *wrapper_calloc(size_t, size_t, const char *); void *wrapper_realloc(void *, size_t, const char *); char *wrapper_strdup(const char *, const char *); void wrapper_free(void *); void wrapper_histogram(void); void wrapper_checkForLeaks(void); #ifdef USE_W_MALLOC #define w_malloc(size) wrapper_malloc(size, __func__) #define w_calloc(nb, size) wrapper_calloc(nb, size, __func__) #define w_strdup(s) wrapper_strdup(s, __func__) #define w_free(p) wrapper_free(p) #define w_realloc(ptr, size) wrapper_realloc(ptr, size, __func__) #define w_histogram() wrapper_histogram() #define w_checkForLeaks() wrapper_checkForLeaks() #else /* standard library functions */ #include <stdlib.h> #include <string.h> /* set macros to default system functions */ #define w_malloc(size) malloc(size) #define w_calloc(nb, size) calloc(nb, size) #define w_realloc(ptr, size) realloc(ptr, size) #define w_strdup(s) strdup(s) #define w_free(ptr) free(ptr) /* set macros to null statements */ #define w_checkForLeaks() ; #define w_histogram() ; #endif /* USE_W_MALLOC */ #endif /* __W_MALLOC_H__ */