From: mquinson Date: Tue, 6 Jul 2004 07:34:20 +0000 (+0000) Subject: in gras_dynar_cursor_rm, we want to get the content to free it if there is a X-Git-Tag: v3.3~5165 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/69872d0bb4e246568d1a2ad67d3239f5e68855dd?ds=sidebyside in gras_dynar_cursor_rm, we want to get the content to free it if there is a free_func. But take care of writing it into a variable big enough, little scarabee... git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@181 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index 8a65bc58ee..3cedd0e816 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -551,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); + } }