From 62e30d2b56f552a402c451145b4b1de318ff3fef Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Tue, 13 Jan 2004 23:20:06 +0000 Subject: [PATCH] Emalloc(), Erealloc(): added git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@578 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/src/wrappers.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/util-vserver/src/wrappers.h b/util-vserver/src/wrappers.h index 2d17315..ee8542c 100644 --- a/util-vserver/src/wrappers.h +++ b/util-vserver/src/wrappers.h @@ -228,6 +228,27 @@ Edup2(int oldfd, int newfd) return res; } +inline static UNUSED void * +Emalloc(size_t size) +{ + register void *res = malloc(size); + FatalErrnoError(res==0 && size!=0, "malloc()"); + return res; +} + +/*@unused@*/ +inline static /*@null@*//*@only@*/ void * +Erealloc(/*@only@*//*@out@*//*@null@*/ void *ptr, + size_t new_size) + /*@ensures maxSet(result) == new_size@*/ + /*@modifies *ptr@*/ +{ + register void *res = realloc(ptr, new_size); + FatalErrnoError(res==0 && new_size!=0, "realloc()"); + + return res; +} + #undef WRAPPER_DECL #endif // H_UTIL_VSERVER_SRC_WRAPPERS_H -- 1.8.1.5