Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: do not assume that the object still exists when removing an element, it might...
authorcristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 12 May 2010 17:44:16 +0000 (17:44 +0000)
committercristianrosa <cristianrosa@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 12 May 2010 17:44:16 +0000 (17:44 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7742 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/setset.c
src/xbt/setset_private.h

index cbdb2b8..ece4fa5 100644 (file)
@@ -30,9 +30,9 @@ xbt_setset_t xbt_setset_new(unsigned int size)
 void xbt_setset_destroy(xbt_setset_t setset)
 {
   xbt_dynar_free(&setset->elm_array);
 void xbt_setset_destroy(xbt_setset_t setset)
 {
   xbt_dynar_free(&setset->elm_array);
+  /* FIXME: we should free all the sets in the fifo setset->sets */
   xbt_fifo_free(setset->sets);
   xbt_free(setset);
   xbt_fifo_free(setset->sets);
   xbt_free(setset);
-  /* FIXME: check if we should trash the stored objects */
 }
 
 /* Add an element to the setset, this will assign to it an index */
 }
 
 /* Add an element to the setset, this will assign to it an index */
@@ -44,7 +44,7 @@ xbt_setset_elm_entry_t _xbt_setset_elm_add(xbt_setset_t setset, void *obj)
   xbt_setset_elm_entry_t first_elm = 
     (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, 0);
   
   xbt_setset_elm_entry_t first_elm = 
     (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, 0);
   
-  /* Before create a new elm entry check if there is one in the free elm list.*/
+  /* Before create a new elm entry check if there is one in the free elm list. */
   /* If there is not free elm entries, then create a new one  */
   if(first_elm->free.next != 0){
     e->ID = first_elm->free.next;
   /* If there is not free elm entries, then create a new one  */
   if(first_elm->free.next != 0){
     e->ID = first_elm->free.next;
@@ -65,13 +65,14 @@ void _xbt_setset_elm_remove(xbt_setset_t setset, unsigned long idx)
 {
   xbt_setset_elm_entry_t e_entry = xbt_dynar_get_ptr(setset->elm_array, idx);
   xbt_setset_elm_entry_t first_free = NULL;
 {
   xbt_setset_elm_entry_t e_entry = xbt_dynar_get_ptr(setset->elm_array, idx);
   xbt_setset_elm_entry_t first_free = NULL;
-  
+
   /* Decrease the refcount and proceed only if it is 0 */
   if(--e_entry->info.refcount > 0)
     return;
 
   /* Erase object ID */
   /* Decrease the refcount and proceed only if it is 0 */
   if(--e_entry->info.refcount > 0)
     return;
 
   /* Erase object ID */
-  e_entry->info.obj->ID = 0;
+  /* FIXME: do not assume that the object still exists, it might be deallocated */
+  /*e_entry->info.obj->ID = 0;*/
   
   /* Link the elm entry to the list of free ones */
   first_free = xbt_dynar_get_ptr(setset->elm_array, 0);
   
   /* Link the elm entry to the list of free ones */
   first_free = xbt_dynar_get_ptr(setset->elm_array, 0);
index 4daf3a9..1db9798 100644 (file)
@@ -12,7 +12,7 @@ typedef struct s_xbt_setset_elm {
 typedef union u_xbt_setset_elm_entry {
   /* Information when the entry is being used */
   struct {
 typedef union u_xbt_setset_elm_entry {
   /* Information when the entry is being used */
   struct {
-    unsigned int refcount;
+    unsigned int refcount;    
     xbt_setset_elm_t obj;
   } info;
   /* Information when the entry is free */
     xbt_setset_elm_t obj;
   } info;
   /* Information when the entry is free */