3 /* gras/sysdep.h -- all system dependency */
4 /* no system header should be loaded out of this file so that we have only */
5 /* one file to check when porting to another OS */
7 /* Authors: Martin Quinson */
8 /* Copyright (C) 2004 the OURAGAN project. */
10 /* This program is free software; you can redistribute it and/or modify it
11 under the terms of the license (GNU LGPL) which comes with this package. */
13 #include "xbt/sysdep.h"
15 #include "xbt/error.h"
19 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, xbt, "System dependency");
22 **** Memory management
25 void* gras_malloc (long int bytes) {
26 void *ptr = (bytes == 0 ? NULL : (void*) malloc ((size_t) bytes));
27 gras_assert1(ptr, "Malloc of %ld bytes failed",bytes);
30 void* gras_malloc0 (long int bytes) {
31 void *ptr = (bytes == 0 ? NULL : (void*) calloc ((size_t) bytes, 1));
32 gras_assert1(ptr, "Malloc of %ld bytes failed",bytes);
36 void* gras_realloc (void *memory, long int bytes) {
41 void *ptr = (void*) realloc (memory, (size_t) bytes);
42 gras_assert1(ptr, "Realloc of %ld bytes failed",bytes);
46 char* gras_strdup (const char* str) {
47 char *ret = (char*)strdup(str);
48 gras_assert0(ret, "String duplication failed");
52 void gras_free (void *memory) {
61 void gras_abort(void) {