X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/916a2445383d3ed94e8f17ca33e45333aea2251c..91225594356c775dd384e44f5b5008cb3d9b7219:/src/xbt/dynar.c diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index b039d3495f..3cedd0e816 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -10,8 +10,7 @@ #include "gras_private.h" - -GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dynar,GRAS); +GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(dynar,tbx); struct gras_dynar_s { size_t size; @@ -552,7 +551,21 @@ void gras_dynar_cursor_rm(gras_dynar_t * dynar, int * const cursor) { void *dst; - gras_dynar_remove_at(dynar,(*cursor)--,&dst); - if (dynar->free) - (dynar->free)(dst); + if (dynar->elmsize > sizeof(void*)) { + DEBUG0("Elements too big to fit into a pointer"); + if (dynar->free) { + dst=malloc(dynar->elmsize); + gras_dynar_remove_at(dynar,(*cursor)--,dst); + (dynar->free)(dst); + free(dst); + } else { + DEBUG0("Ok, we dont care about the element when no free function"); + gras_dynar_remove_at(dynar,(*cursor)--,NULL); + } + + } else { + gras_dynar_remove_at(dynar,(*cursor)--,&dst); + if (dynar->free) + (dynar->free)(dst); + } }