OSDN Git Service

Change behavior of checking closed sockets for some Windows 2000 environments.
[ffftp/ffftp.git] / putty / PUTTYMEM.H
1 /*\r
2  * PuTTY memory-handling header.\r
3  */\r
4 \r
5 #ifndef PUTTY_PUTTYMEM_H\r
6 #define PUTTY_PUTTYMEM_H\r
7 \r
8 #include <stddef.h>                    /* for size_t */\r
9 #include <string.h>                    /* for memcpy() */\r
10 \r
11 \r
12 /* #define MALLOC_LOG  do this if you suspect putty of leaking memory */\r
13 #ifdef MALLOC_LOG\r
14 #define smalloc(z) (mlog(__FILE__,__LINE__), safemalloc(z,1))\r
15 #define snmalloc(z,s) (mlog(__FILE__,__LINE__), safemalloc(z,s))\r
16 #define srealloc(y,z) (mlog(__FILE__,__LINE__), saferealloc(y,z,1))\r
17 #define snrealloc(y,z,s) (mlog(__FILE__,__LINE__), saferealloc(y,z,s))\r
18 #define sfree(z) (mlog(__FILE__,__LINE__), safefree(z))\r
19 void mlog(char *, int);\r
20 #else\r
21 #define smalloc(z) safemalloc(z,1)\r
22 #define snmalloc safemalloc\r
23 #define srealloc(y,z) saferealloc(y,z,1)\r
24 #define snrealloc saferealloc\r
25 #define sfree safefree\r
26 #endif\r
27 \r
28 void *safemalloc(size_t, size_t);\r
29 void *saferealloc(void *, size_t, size_t);\r
30 void safefree(void *);\r
31 \r
32 /*\r
33  * Direct use of smalloc within the code should be avoided where\r
34  * possible, in favour of these type-casting macros which ensure\r
35  * you don't mistakenly allocate enough space for one sort of\r
36  * structure and assign it to a different sort of pointer.\r
37  */\r
38 #define snew(type) ((type *)snmalloc(1, sizeof(type)))\r
39 #define snewn(n, type) ((type *)snmalloc((n), sizeof(type)))\r
40 #define sresize(ptr, n, type) ((type *)snrealloc((ptr), (n), sizeof(type)))\r
41 \r
42 #endif\r