+XBT_PUBLIC(char*) bprintf (const char*fmt, ...) _XBT_GNUC_PRINTF(1,2);
+
+/** @addtogroup XBT_syscall
+ * @brief Malloc and associated functions, killing the program on error (with \ref XBT_ex)
+ *
+ * @{
+ */
+
+#if defined(__GNUC__) || defined(DOXYGEN)
+/** @brief Like strdup, but xbt_die() on error */
+static XBT_INLINE char *xbt_strdup(const char *s) {
+ char *res = NULL;
+ if (s) {
+ res=strdup(s);
+ if (!res)
+ xbt_die("memory allocation error (strdup returned NULL)");
+ }
+ return res;
+}
+/** @brief Like malloc, but xbt_die() on error
+ @hideinitializer */
+static XBT_INLINE void *xbt_malloc(unsigned int n){
+ void *res;
+// if (n==0) xbt_die("malloc(0) is not portable");
+ res=malloc(n);
+ if (!res)
+ xbt_die(bprintf("Memory allocation of %d bytes failed",n));
+ return res;
+}
+
+/** @brief like malloc, but xbt_die() on error and memset data to 0
+ @hideinitializer */
+static XBT_INLINE void *xbt_malloc0(unsigned int n) {
+ void *res;
+// if (n==0) xbt_die("calloc(0) is not portable");
+ res=calloc(n,1);
+ if (!res)
+ xbt_die(bprintf("Memory callocation of %d bytes failed",n));
+ return res;
+}