Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

mem/memory.cpp

Go to the documentation of this file.
00001 
00021 #include "memory.h"
00022 #ifndef _MEM_MEM_CPP_
00023 #define _MEM_MEM_CPP_
00024 
00025 static const char memid[] = "\100$ Free Agent: memory.cpp, v 0.1 2002/05/29 red0x Exp $";
00026 
00032 template<class T>
00033 inline void agent_zap(T & x)
00034 {
00035     {assert(x != NULL);}
00036     delete x;
00037     x = NULL;
00038 }
00039 
00045 template<class T>
00046 inline void agent_zaparr(T & x)
00047 {
00048     {assert(x != NULL);}
00049     delete [] x;
00050     x = NULL;
00051 }
00052 
00060 template<class T>
00061 T *agent_newarr(T **dest, size_t size)
00062 {
00063     {assert(size > 0);}
00064     //add a pad, for security
00065     size_t tmpii = size + SAFE_MEM;
00066     *dest = new T[tmpii];
00067     //clear it
00068     memset(*dest, 0, tmpii);
00069     return *dest;
00070 }
00071 
00078 template<class T>
00079 T *agent_new(T **dest)
00080 {
00081     *dest = new T;
00082     return *dest;
00083 }
00084                                             
00085 #endif

Generated at Thu May 30 15:12:33 2002 for Freeagent by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001