Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
if (flags & __GFP_ZERO)
memset(new, 0, size);
- memcpy(new, old,
- min(malloc_usable_size(old),
- malloc_usable_size(new)));
- free(old);
+ if (old) {
+ memcpy(new, old,
+ min(malloc_usable_size(old),
+ malloc_usable_size(new)));
+ free(old);
+ }
return new;
}
#include <linux/uuid.h>
#include "ccan/darray/darray.h"
-void die(const char *, ...);
+#define noreturn __attribute__((noreturn))
+
+void die(const char *, ...) noreturn;
char *mprintf(const char *, ...)
__attribute__ ((format (printf, 1, 2)));
void *xcalloc(size_t, size_t);