projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enhance my 'sresize' macro so that it type-checks the pointer you pass
[u/mdw/putty]
/
puttymem.h
diff --git
a/puttymem.h
b/puttymem.h
index
06c294d
..
6ef3f79
100644
(file)
--- 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 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
#endif