Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
2ac08715081d5ebab958e2becd0884336b7fd013
[simgrid.git] / src / xbt / sysdep.c
1 /* $Id$ */
2
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                            */
6
7 /* Authors: Martin Quinson                                                  */
8 /* Copyright (C) 2004 the OURAGAN project.                                  */
9
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. */
12
13 #include "gras_private.h"
14
15 #include <stdlib.h>
16
17 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(sysdep, gros, "System dependency");
18
19 /****
20  **** Memory management
21  ****/
22
23 void* gras_malloc  (long int bytes) {
24    return bytes == 0 ? NULL : (void*) malloc ((size_t) bytes);
25 }
26 void* gras_malloc0 (long int bytes) {
27    return bytes == 0 ? NULL : (void*) calloc ((size_t) bytes, 1);
28 }
29
30 void* gras_realloc (void  *memory, long int bytes) {
31    if (bytes == 0) {
32       gras_free(memory);
33       return NULL;
34    } else {
35       return (void*) realloc (memory, (size_t) bytes);
36    }
37 }
38
39 void  gras_free (void  *memory) {
40    if (memory) {
41       free (memory);
42    }
43 }
44
45 /****
46  **** Misc
47  ****/
48
49 void gras_abort(void) {
50    abort();
51 }