From: simon Date: Fri, 18 May 2012 19:51:11 +0000 (+0000) Subject: Enhance my 'sresize' macro so that it type-checks the pointer you pass X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/9c3b78f422dbffc8fcd93fd2743f75fca45a926a Enhance my 'sresize' macro so that it type-checks the pointer you pass _in_ to it, as well as the one it returns. Why have I never thought of doing that before?! git-svn-id: svn://svn.tartarus.org/sgt/putty@9539 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/puttymem.h b/puttymem.h index 06c294d9..6ef3f794 100644 --- a/puttymem.h +++ b/puttymem.h @@ -37,6 +37,7 @@ void safefree(void *); */ #define snew(type) ((type *)snmalloc(1, sizeof(type))) #define snewn(n, type) ((type *)snmalloc((n), sizeof(type))) -#define sresize(ptr, n, type) ((type *)snrealloc((ptr), (n), sizeof(type))) +#define sresize(ptr, n, type) \ + ((type *)snrealloc((sizeof((type *)0 == (ptr)), (ptr)), (n), sizeof(type))) #endif