-BEGIN_DECL
-#if 0
-#define __CALLOC_OP(n, s) calloc((n), (s))
- #define __REALLOC_OP(n, s) realloc((n), (s))
-#define CALLOC(n, s) ((__CALLOC_OP ((n)?:(FAILURE("attempt to alloc 0 bytes"), 0), (s)?:(FAILURE("attempt to alloc 0 bytes"), 0)))?:(FAILURE("memory allocation error"), NULL))
- /* #define REALLOC(p, s) ((__REALLOC_OP ((p), (s)?:(FAILURE("attempt to alloc 0 bytes"), 0)))?:(FAILURE("memory reallocation error"), NULL)) */
- #define REALLOC(p, s) (__REALLOC_OP ((p), (s)))
-#endif
+#include "xbt/error.h"
+
+BEGIN_DECL()
+/** @addtogroup XBT_syscall
+ * @{
+ */
+
+#ifdef __GNUC__
+/** @brief like strdup, but xbt_die() on error */
+static inline char *xbt_strdup(const char *s) {
+ char *res = NULL;
+ if (s) {
+ res=strdup(s);
+ if (!res)
+ xbt_die("memory allocation error");
+ }
+ return res;
+}
+/** @brief like malloc, but xbt_die() on error
+ @hideinitializer */
+static inline void *xbt_malloc(int n){
+ void *res=malloc(n);
+ if (!res)
+ xbt_die("Memory allocation failed");
+ return res;
+}
+
+/** @brief like malloc, but xbt_die() on error and memset data to 0
+ @hideinitializer */
+static inline void *xbt_malloc0(int n) {
+ void *res=calloc(n,1);
+ if (!res)
+ xbt_die("Memory callocation failed");
+ return res;
+}