X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=cache.h;h=3277d48708f885fa1b7cc56c9d16061c65a2eeb9;hb=9831d8f86095edde393e495d7a55cab9d35d5d05;hp=4ef80c392adb19df21a779edab366f99b7850e54;hpb=f5b913c9cb52cee019585375546817cfe5c75426;p=git.git diff --git a/cache.h b/cache.h index 4ef80c39..3277d487 100644 --- a/cache.h +++ b/cache.h @@ -147,4 +147,20 @@ extern void *read_tree_with_tree_or_commit_sha1(const unsigned char *sha1, unsigned long *size, unsigned char *tree_sha1_ret); +static inline void *xmalloc(int size) +{ + void *ret = malloc(size); + if (!ret) + die("Out of memory, malloc failed"); + return ret; +} + +static inline void *xrealloc(void *ptr, int size) +{ + void *ret = realloc(ptr, size); + if (!ret) + die("Out of memory, realloc failed"); + return ret; +} + #endif /* CACHE_H */