diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-11-30 01:48:19 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-11-30 01:48:19 -0500 |
commit | c6bbee48816f197a7d99bb61908a6d0601775a9c (patch) | |
tree | 2fbcbc8a27cfca557622f5d4d95528f926f1daf4 | |
parent | 003caf1d7fdf6467b0bc41ffefeca0dc8ec0ffb8 (diff) | |
download | dimension-c6bbee48816f197a7d99bb61908a6d0601775a9c.tar.xz |
Don't use alloca() in dmnsn_add_map_entry().
It's bad for portability, and not even in a hot code path.
-rw-r--r-- | libdimension/map.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libdimension/map.c b/libdimension/map.c index ba1adb6..2fd0c13 100644 --- a/libdimension/map.c +++ b/libdimension/map.c @@ -24,7 +24,6 @@ */ #include "dimension.h" -#include <alloca.h> /** An [index, object] pair. */ typedef struct dmnsn_map_entry { @@ -61,7 +60,8 @@ dmnsn_delete_map(dmnsn_map *map) void dmnsn_add_map_entry(dmnsn_map *map, double n, const void *obj) { - dmnsn_map_entry *entry = alloca(sizeof(dmnsn_map_entry) + map->obj_size); + dmnsn_map_entry *entry + = dmnsn_malloc(sizeof(dmnsn_map_entry) + map->obj_size); entry->n = n; memcpy(entry->object, obj, map->obj_size); @@ -74,6 +74,7 @@ dmnsn_add_map_entry(dmnsn_map *map, double n, const void *obj) } dmnsn_array_insert(map->array, i + 1, entry); + dmnsn_free(entry); } size_t |