X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/272ccad1b68b6d9c17069f3c934886925bb15b5d..c8c6d0ade908d7787bda1c278511c3e404097671:/src/xbt/snprintf.c diff --git a/src/xbt/snprintf.c b/src/xbt/snprintf.c index 1e443fb690..641f294e10 100644 --- a/src/xbt/snprintf.c +++ b/src/xbt/snprintf.c @@ -422,6 +422,9 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, #endif #endif + /* FIXME: better place */ +#include "xbt/sysdep.h" + /* declarations */ static char credits[] = "\n\ @@ -447,7 +450,7 @@ int asprintf(char **ptr, const char *fmt, /*args */ ...) str_l = portable_vsnprintf(NULL, (size_t) 0, fmt, ap); va_end(ap); assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ - *ptr = (char *) malloc(str_m = (size_t) str_l + 1); + *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; @@ -476,7 +479,7 @@ int vasprintf(char **ptr, const char *fmt, va_list ap) va_end(ap2); } assert(str_l >= 0); /* possible integer overflow if str_m > INT_MAX */ - *ptr = (char *) malloc(str_m = (size_t) str_l + 1); + *ptr = (char *) xbt_malloc(str_m = (size_t) str_l + 1); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; @@ -504,7 +507,7 @@ int asnprintf(char **ptr, size_t str_m, const char *fmt, /*args */ ...) /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ if (str_m == 0) { /* not interested in resulting string, just return size */ } else { - *ptr = (char *) malloc(str_m); + *ptr = (char *) xbt_malloc(str_m); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; @@ -538,7 +541,7 @@ int vasnprintf(char **ptr, size_t str_m, const char *fmt, va_list ap) /* if str_m is 0, no buffer is allocated, just set *ptr to NULL */ if (str_m == 0) { /* not interested in resulting string, just return size */ } else { - *ptr = (char *) malloc(str_m); + *ptr = (char *) xbt_malloc(str_m); if (*ptr == NULL) { errno = ENOMEM; str_l = -1; @@ -1165,9 +1168,6 @@ int portable_vsnprintf(char *str, size_t str_m, const char *fmt, #endif - /* FIXME: better place */ -#include "xbt/sysdep.h" - char *bvprintf(const char *fmt, va_list ap) { char *res; @@ -1176,7 +1176,7 @@ char *bvprintf(const char *fmt, va_list ap) /* Do not want to use xbt_die() here, as it uses the logging * infrastucture and may fail to allocate memory too. */ fprintf(stderr, "bprintf: vasprintf failed. Aborting.\n"); - abort(); + xbt_abort(); } return res; }