X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c5d0a2b0b3b1bba7f39946169f3ab2f63bcdd28a..b2991a6a2a69c2c74cffc6e54c1888ad70824c81:/src/xbt/dynar.c diff --git a/src/xbt/dynar.c b/src/xbt/dynar.c index 2c1e7dc891..7a567b9d28 100644 --- a/src/xbt/dynar.c +++ b/src/xbt/dynar.c @@ -381,6 +381,10 @@ xbt_dynar_insert_at(xbt_dynar_t const dynar, * * Get the Nth element of a dynar, removing it from the dynar and moving * all subsequent values to one position left in the dynar. + * + * If the object argument of this function is a non-null pointer, the removed + * element is copied to this address. If not, the element is freed using the + * free_f function passed at dynar creation. */ void xbt_dynar_remove_at(xbt_dynar_t const dynar, @@ -428,7 +432,7 @@ xbt_dynar_search(xbt_dynar_t const dynar, void *const elem) { int it; - for (it=0; it< dynar->size; it++) + for (it=0; it< dynar->used; it++) if (!memcmp(_xbt_dynar_elm(dynar, it),elem,dynar->elmsize)) return it; @@ -593,25 +597,8 @@ xbt_dynar_cursor_get(const xbt_dynar_t dynar, */ void xbt_dynar_cursor_rm(xbt_dynar_t dynar, int * const cursor) { - void *dst; - - if (dynar->elmsize > sizeof(void*)) { - DEBUG0("Elements too big to fit into a pointer"); - if (dynar->free_f) { - dst=xbt_malloc(dynar->elmsize); - xbt_dynar_remove_at(dynar,(*cursor)--,dst); - (dynar->free_f)(dst); - free(dst); - } else { - DEBUG0("Ok, we dont care about the element without free function"); - xbt_dynar_remove_at(dynar,(*cursor)--,NULL); - } - - } else { - xbt_dynar_remove_at(dynar,(*cursor)--,&dst); - if (dynar->free_f) - (dynar->free_f)(dst); - } + + xbt_dynar_remove_at(dynar,(*cursor)--,NULL); } #ifdef SIMGRID_TEST