summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-11-30 01:48:19 -0500
committerTavian Barnes <tavianator@gmail.com>2010-11-30 01:48:19 -0500
commitc6bbee48816f197a7d99bb61908a6d0601775a9c (patch)
tree2fbcbc8a27cfca557622f5d4d95528f926f1daf4 /libdimension
parent003caf1d7fdf6467b0bc41ffefeca0dc8ec0ffb8 (diff)
downloaddimension-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.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/map.c5
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