X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a6f0160d9f260a762e0ddbc0fffa9fb45d53826c..3d0d626e19a7b79320e7d922c9c1dcf122076cea:/src/xbt/sysdep.c diff --git a/src/xbt/sysdep.c b/src/xbt/sysdep.c index 2ac0871508..2575bf97fb 100644 --- a/src/xbt/sysdep.c +++ b/src/xbt/sysdep.c @@ -21,10 +21,14 @@ GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, gros, "System dependency"); ****/ void* gras_malloc (long int bytes) { - return bytes == 0 ? NULL : (void*) malloc ((size_t) bytes); + void *ptr = (bytes == 0 ? NULL : (void*) malloc ((size_t) bytes)); + gras_assert1(ptr, "Malloc of %ld bytes failed",bytes); + return ptr; } void* gras_malloc0 (long int bytes) { - return bytes == 0 ? NULL : (void*) calloc ((size_t) bytes, 1); + void *ptr = (bytes == 0 ? NULL : (void*) calloc ((size_t) bytes, 1)); + gras_assert1(ptr, "Malloc of %ld bytes failed",bytes); + return ptr; } void* gras_realloc (void *memory, long int bytes) { @@ -32,14 +36,20 @@ void* gras_realloc (void *memory, long int bytes) { gras_free(memory); return NULL; } else { - return (void*) realloc (memory, (size_t) bytes); + void *ptr = (void*) realloc (memory, (size_t) bytes); + gras_assert1(ptr, "Realloc of %ld bytes failed",bytes); + return ptr; } } +char* gras_strdup (const char* str) { + char *ret = (char*)strdup(str); + gras_assert0(ret, "String duplication failed"); + return ret; +} void gras_free (void *memory) { - if (memory) { - free (memory); - } + if (memory) + free (memory); } /****