Skip to content

Commit

Permalink
Enhance my 'sresize' macro so that it type-checks the pointer you pass
Browse files Browse the repository at this point in the history
_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
  • Loading branch information
simon committed May 18, 2012
1 parent acdea65 commit ffd0e31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion puttymem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ffd0e31

Please sign in to comment.