Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

puttymem.h

00001 /*
00002  * PuTTY memory-handling header.
00003  */
00004 
00005 #ifndef PUTTY_PUTTYMEM_H
00006 #define PUTTY_PUTTYMEM_H
00007 
00008 #include <stddef.h>                    /* for size_t */
00009 #include <string.h>                    /* for memcpy() */
00010 
00011 
00012 /* #define MALLOC_LOG  do this if you suspect putty of leaking memory */
00013 #ifdef MALLOC_LOG
00014 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z))
00015 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z))
00016 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))
00017 void mlog(char *, int);
00018 #else
00019 #define smalloc safemalloc
00020 #define srealloc saferealloc
00021 #define sfree safefree
00022 #endif
00023 
00024 void *safemalloc(size_t);
00025 void *saferealloc(void *, size_t);
00026 void safefree(void *);
00027 
00028 
00029 /* smalloc a thing */
00030 #define smalloca(type) ((type *) smalloc (sizeof (type)))
00031 /* smalloc a copy of a thing */
00032 #define smallocc(ptr) memcpy (smalloc (sizeof (*ptr)), ptr, sizeof (*ptr))
00033 /* smalloc n things */
00034 #define smallocn(n,type) ((type *) smalloc ((n) * sizeof (type)))
00035 
00036 
00037 #endif

Generated on Sun Feb 9 13:01:29 2003 for PuTTY by doxygen1.2.18