Skip to content
Snippets Groups Projects
Commit 6ab4820c authored by Tim Wickberg's avatar Tim Wickberg
Browse files

Tweak safe_xcalloc / safe_xmalloc macros to allow zero size allocations.

A lot of places rely on a zero size (or, after xcalloc conversion, count)
resulting in a NULL return, so stop xassert()'ing those cases and avoid
jumping to the unpack_error label.
parent 2707a9c0
No related branches found
No related tags found
No related merge requests found
...@@ -367,15 +367,12 @@ int unpackmem_array(char *valp, uint32_t size_valp, Buf buffer); ...@@ -367,15 +367,12 @@ int unpackmem_array(char *valp, uint32_t size_valp, Buf buffer);
} while (0) } while (0)
#define safe_xcalloc(p, cnt, sz) do { \ #define safe_xcalloc(p, cnt, sz) do { \
assert(cnt); \ if (!(p = try_xcalloc(cnt, sz)) && cnt && sz) \
assert(sz); \
if (!(p = try_xcalloc(cnt, sz))) \
goto unpack_error; \ goto unpack_error; \
} while (0) } while (0)
#define safe_xmalloc(p, sz) do { \ #define safe_xmalloc(p, sz) do { \
assert(sz); \ if (!(p = try_xmalloc(sz)) && sz) \
if (!(p = try_xmalloc(sz))) \
goto unpack_error; \ goto unpack_error; \
} while (0) } while (0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment