summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_array.c
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@samsung.com>2013-11-29 15:30:32 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-29 15:33:51 +0900
commitaefd608453c47ff03d60d1a34f0aba73ad290016 (patch)
treef6b8fe531bacf260d27c58216910a32ea8d4310d /src/lib/eina/eina_array.c
parent50e74f02d47aa70e346d6300c5adc637243bd0eb (diff)
eina: fix rounding logic to avoid making the array to short.
I have no idea how the previous formula was supposed to work at all, but this one is the same as our alignof code to make sure we do allocate to the really nearest size and don't do over allocation. Additionnaly it works.
Diffstat (limited to '')
-rw-r--r--src/lib/eina/eina_array.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib/eina/eina_array.c b/src/lib/eina/eina_array.c
index ab853a01ea..dddcf732bb 100644
--- a/src/lib/eina/eina_array.c
+++ b/src/lib/eina/eina_array.c
@@ -363,7 +363,7 @@ eina_array_remove(Eina_Array *array, Eina_Bool (*keep)(void *data,
363 else 363 else
364 { 364 {
365 // realloc back down - rounding up to the nearest step size 365 // realloc back down - rounding up to the nearest step size
366 size = (array->count + array->step - 1) % array->step; 366 size = ((array->count / array->step) + (array->count % array->step ? 1 : 0)) * array->step;
367 tmp = realloc(array->data, sizeof(void *) * size); 367 tmp = realloc(array->data, sizeof(void *) * size);
368 if (!tmp) return EINA_FALSE; 368 if (!tmp) return EINA_FALSE;
369 array->total = size; 369 array->total = size;