cleanups
[util-vserver.git] / util-vserver / src / wrappers.h
index 2d17315..632be13 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
+#include <sys/ioctl.h>
 
 #define WRAPPER_DECL   UNUSED ALWAYSINLINE
 
@@ -228,6 +229,50 @@ Edup2(int oldfd, int newfd)
   return res;
 }
 
+inline static WRAPPER_DECL void *
+Emalloc(size_t size)
+{
+  register void               *res = malloc(size);
+  FatalErrnoError(res==0 && size!=0, "malloc()");
+  return res;
+}
+
+/*@unused@*/
+inline static WRAPPER_DECL /*@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;
+}
+
+inline static WRAPPER_DECL off_t
+Elseek(int fildes, off_t offset, int whence)
+{
+  off_t         res = lseek(fildes, offset, whence);
+  FatalErrnoError(res==(off_t)-1, "lseek()");
+  return res;
+}
+
+inline static WRAPPER_DECL int
+Emkstemp(char *template)
+{
+  int          res = mkstemp(template);
+  FatalErrnoError(res==-1, "mkstemp()");
+  return res;
+}
+
+inline static WRAPPER_DECL void
+Eioctl(int fd, int request, void *p)
+{
+  int   res = ioctl(fd, request, p);
+  FatalErrnoError(res<0, "ioctl()");
+}
+
 #undef WRAPPER_DECL
 
 #endif //  H_UTIL_VSERVER_SRC_WRAPPERS_H