00001
00002
00003
00004
00005 #ifndef PUTTY_PUTTYMEM_H
00006 #define PUTTY_PUTTYMEM_H
00007
00008 #include <stddef.h>
00009 #include <string.h>
00010
00011
00012
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
00030 #define smalloca(type) ((type *) smalloc (sizeof (type)))
00031
00032 #define smallocc(ptr) memcpy (smalloc (sizeof (*ptr)), ptr, sizeof (*ptr))
00033
00034 #define smallocn(n,type) ((type *) smalloc ((n) * sizeof (type)))
00035
00036
00037 #endif