Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Using xbt_new0 instead of callox in fifo and heap
authoralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 3 Nov 2004 22:51:34 +0000 (22:51 +0000)
committeralegrand <alegrand@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 3 Nov 2004 22:51:34 +0000 (22:51 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@481 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/fifo.c
src/xbt/heap.c

index 25413c9..a2e952f 100644 (file)
@@ -3,7 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
    under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include <stdlib.h>
+#include "xbt/sysdep.h"
 #include "fifo_private.h"
 
 /*
 #include "fifo_private.h"
 
 /*
@@ -12,7 +12,7 @@
 xbt_fifo_t xbt_fifo_new(void)
 {
   xbt_fifo_t fifo;
 xbt_fifo_t xbt_fifo_new(void)
 {
   xbt_fifo_t fifo;
-  fifo = (xbt_fifo_t) calloc(1, sizeof(struct xbt_fifo));
+  fifo = xbt_new0(struct xbt_fifo,1);
   return fifo;
 }
 
   return fifo;
 }
 
@@ -202,7 +202,7 @@ void **xbt_fifo_to_array(xbt_fifo_t f)
   if (f->count == 0)
     return NULL;
   else
   if (f->count == 0)
     return NULL;
   else
-    array = (void **) calloc(f->count, sizeof(void *));
+    array = xbt_new0(void *, f->count);
 
   for (i = 0, b = xbt_fifo_getFirstitem(f); b; i++, b = b->next) {
     array[i] = b->content;
 
   for (i = 0, b = xbt_fifo_getFirstitem(f); b; i++, b = b->next) {
     array[i] = b->content;
@@ -231,7 +231,7 @@ xbt_fifo_t xbt_fifo_copy(xbt_fifo_t f)
  */
 xbt_fifo_item_t xbt_fifo_newitem(void)
 {
  */
 xbt_fifo_item_t xbt_fifo_newitem(void)
 {
-  return (xbt_fifo_item_t) calloc(1, sizeof(struct xbt_fifo_item));
+  return xbt_new0(struct xbt_fifo_item,1);
 }
 
 void xbt_fifo_set_item_content(xbt_fifo_item_t i , void *v)
 }
 
 void xbt_fifo_set_item_content(xbt_fifo_item_t i , void *v)
index c01e8b6..355a401 100644 (file)
@@ -5,6 +5,7 @@
 /* This program is free software; you can redistribute it and/or modify it
    under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
    under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "xbt/sysdep.h"
 #include "heap_private.h"
 
 /**
 #include "heap_private.h"
 
 /**
  */
 xbt_heap_t xbt_heap_new(int init_size, void_f_pvoid_t * const free_func)
 {
  */
 xbt_heap_t xbt_heap_new(int init_size, void_f_pvoid_t * const free_func)
 {
-  xbt_heap_t H = calloc(1, sizeof(struct xbt_heap));
+  xbt_heap_t H = xbt_new0(struct xbt_heap, 1);
   H->size = init_size;
   H->count = 0;
   H->items =
   H->size = init_size;
   H->count = 0;
   H->items =
-      (xbt_heapItem_t) calloc(init_size, sizeof(struct xbt_heapItem));
-  H->free = free;
+      (xbt_heapItem_t) xbt_new0(struct xbt_heapItem, init_size);
+  H->free = free_func;
   return H;
 }
 
   return H;
 }
 
@@ -37,8 +38,8 @@ void xbt_heap_free(xbt_heap_t H)
   if (H->free)
     for (i = 0; i < H->size; i++)
       H->free(H->items[i].content);
   if (H->free)
     for (i = 0; i < H->size; i++)
       H->free(H->items[i].content);
-  free(H->items);
-  free(H);
+  xbt_free(H->items);
+  xbt_free(H);
   return;
 }
 
   return;
 }