From: Martin Quinson Date: Wed, 25 Jan 2017 13:56:22 +0000 (+0100) Subject: reduce the amount of mallocs and use space on the stack X-Git-Tag: v3_15~525 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/344628a21cd5ea8a18f5f61985ad651cf85e9949 reduce the amount of mallocs and use space on the stack --- diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index 62a607ee40..44ce025c6e 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -620,7 +620,7 @@ XBT_PUBLIC(void) xbt_dynar_three_way_partition(xbt_dynar_t const dynar, int_f_pv unsigned long int p = -1; unsigned long int q = dynar->used; const unsigned long elmsize = dynar->elmsize; - void *tmp = xbt_malloc(elmsize); + char* tmp[elmsize]; void *elm; for (i = 0; i < q;) { @@ -643,7 +643,6 @@ XBT_PUBLIC(void) xbt_dynar_three_way_partition(xbt_dynar_t const dynar, int_f_pv } } } - xbt_free(tmp); } /** @brief Transform a dynar into a nullptr terminated array.