|
Aegis
4.25.D505
|
00001 // 00002 // aegis - project change supervisor 00003 // Copyright (C) 1991-1994, 1999, 2004-2006, 2008, 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #ifndef COMMON_MEM_H 00020 #define COMMON_MEM_H 00021 00027 #include <common/ac/stddef.h> 00028 #include <common/ac/new.h> 00029 00044 void *mem_alloc(size_t nbytes); 00045 00046 #ifdef DMALLOC 00047 void *dmem_alloc(const char *file, int line, size_t nbytes); 00048 #define mem_alloc(nbytes) dmem_alloc(__FILE__, __LINE__, (nbytes)) 00049 #endif 00050 00065 void *mem_alloc_clear(size_t nbytes); 00066 #ifdef DMALLOC 00067 void *dmem_alloc_clear(const char *file, int line, size_t nbytes); 00068 #define mem_alloc_clear(nbytes) dmem_alloc_clear(__FILE__, __LINE__, (nbytes)) 00069 #endif 00070 00071 00072 void *mem_change_size(void *, size_t); 00073 #ifdef DMALLOC 00074 void *dmem_change_size(const char *file, int line, void *p, 00075 size_t nbytes); 00076 #define mem_change_size(p, nbytes) \ 00077 dmem_change_size(__FILE__, __LINE__, (p), (nbytes)) 00078 #endif 00079 00080 void mem_free(void *); 00081 #ifdef DMALLOC 00082 void dmem_free(const char *file, int line, void *p); 00083 #define mem_free(p) dmem_free(__FILE__, __LINE__, (p)) 00084 #endif 00085 00086 00097 char *mem_copy_string(const char *arg); 00098 #ifdef DMALLOC 00099 char *dmem_copy_string(const char *file, int line, const char *p); 00100 #define mem_copy_string(p) dmem_copy_string(__FILE__, __LINE__, (p)) 00101 #endif 00102 00103 00116 char *mem_copy_string(const char *arg, size_t len); 00117 #ifdef DMALLOC 00118 char *dmem_copy_string(const char *file, int line, 00119 const char *p, size_t len); 00120 #undef mem_copy_string 00121 #define mem_copy_string(p, ...) \ 00122 dmem_copy_string(__FILE__, __LINE__, (p), ## __VA_ARGS__) 00123 #endif 00124 00125 #if HAVE_HEADER_NEW || HAVE_NEW_H 00126 #define THROW_BAD_ALLOC throw(std::bad_alloc) 00127 #else 00128 #define THROW_BAD_ALLOC 00129 #endif 00130 00131 #ifndef DMALLOC 00132 void *operator new(size_t nbytes) THROW_BAD_ALLOC; 00133 #else 00134 void *operator new(size_t nbytes, const char *file, int line) 00135 THROW_BAD_ALLOC; 00136 #endif 00137 00138 #ifndef DMALLOC 00139 void *operator new[](size_t nbytes) THROW_BAD_ALLOC; 00140 #else 00141 void *operator new[](size_t nbytes, const char *file, int line) 00142 THROW_BAD_ALLOC; 00143 #endif 00144 00145 #ifndef DMALLOC 00146 void operator delete(void *ptr) throw(); 00147 #else 00148 void operator delete(void *ptr, const char *file, int line) throw(); 00149 #endif 00150 00151 #ifndef DMALLOC 00152 void operator delete[](void *ptr) throw(); 00153 #else 00154 void operator delete[](void *ptr, const char *file, int line) throw(); 00155 #endif 00156 00157 #if HAVE_HEADER_NEW || HAVE_NEW_H 00158 00159 #ifndef DMALLOC 00160 void *operator new(size_t nbytes, std::nothrow_t &) throw(); 00161 #else 00162 void *operator new(size_t nbytes, std::nothrow_t &, const char *file, 00163 int line) throw(); 00164 #endif 00165 00166 #ifndef DMALLOC 00167 void *operator new[](size_t nbytes, std::nothrow_t &) throw(); 00168 #else 00169 void *operator new[](size_t nbytes, std::nothrow_t &, const char *file, 00170 int line) throw(); 00171 #endif 00172 00173 #ifndef DMALLOC 00174 void operator delete(void *ptr, std::nothrow_t const &) throw(); 00175 #else 00176 void operator delete(void *ptr, std::nothrow_t const &, const char *file, 00177 int line) throw(); 00178 #endif 00179 00180 #ifndef DMALLOC 00181 void operator delete[](void *ptr, std::nothrow_t const &) throw(); 00182 #else 00183 void operator delete[](void *ptr, std::nothrow_t const &, const char *file, 00184 int line) throw(); 00185 #endif 00186 00187 #ifdef DMALLOC 00188 #define new new(__FILE__, __LINE__) 00189 //#define delete delete(__FILE__, __LINE__) 00190 #endif 00191 00192 #endif 00193 00195 #endif // COMMON_MEM_H 00196 // vim: set ts=8 sw=4 et :
1.7.6.1