/* * ---------------------------------------------------------------- * Night Light Memory Allocation Library Header (memcalls.h) * ---------------------------------------------------------------- * Copyright (C) 1997-2007 Jonas Kvinge * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Last modified by: * Jonas Kvinge (25.03.2007) * */ #ifdef MEMCALLS_H #warning "memcalls.h already included." #else #define MEMCALLS_H #ifndef MEMCALLS_C #define MALLOC_REDEFINE #undef malloc #undef realloc #undef calloc #undef free #define malloc(s) memalloc(__FILE__, __LINE__, __FUNCTION__, (s)) #define realloc(p, s) memrealloc(__FILE__, __LINE__, __FUNCTION__, (p), (s)) #define calloc(n, s) memcalloc(__FILE__, __LINE__, __FUNCTION__, (n), (s)) #define free(p) memfree(__FILE__, __LINE__, __FUNCTION__, (p)) #endif /* FUNCTION PROTOTYPES - JONAS (21.09.2001) */ void *memalloc(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, const size_t MemSize); void *memrealloc(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, void *const OldPTR, const size_t MemSize); void *memcalloc(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, const size_t Elements, const size_t Size); signed short int memfree(const char *const FilePT, const unsigned short int Line, const char *const FunctionPT, void *const MemPTR); #endif