cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=aefd608453c47ff03d60d1a34f0aba73ad290016

commit aefd608453c47ff03d60d1a34f0aba73ad290016
Author: Cedric Bail <cedric.b...@samsung.com>
Date:   Fri Nov 29 15:30:32 2013 +0900

    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.
---
 src/lib/eina/eina_array.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lib/eina/eina_array.c b/src/lib/eina/eina_array.c
index ab853a0..dddcf73 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,
         else
           {
              // realloc back down - rounding up to the nearest step size
-             size = (array->count + array->step - 1) % array->step;
+             size = ((array->count / array->step) + (array->count % 
array->step ? 1 : 0)) * array->step;
              tmp = realloc(array->data, sizeof(void *) * size);
              if (!tmp) return EINA_FALSE;
              array->total = size;

-- 


Reply via email to