Enlightenment CVS committal
Author : cedric
Project : e17
Module : proto/eina
Dir : e17/proto/eina/src/include
Modified Files:
eina_array.h eina_inline_array.x
Log Message:
Fix and improvement for stringshare and array, thanks to the tests suite.
===================================================================
RCS file: /cvs/e/e17/proto/eina/src/include/eina_array.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- eina_array.h 30 Jul 2008 16:34:54 -0000 1.1
+++ eina_array.h 1 Aug 2008 12:26:35 -0000 1.2
@@ -1,6 +1,8 @@
#ifndef EINA_ARRAY_H_
#define EINA_ARRAY_H_
+#include <stdlib.h>
+
#include "eina_types.h"
typedef struct _Eina_Array Eina_Array; /**< A generic vector
*/
@@ -20,5 +22,9 @@
EAPI void eina_array_clean (Eina_Array *array);
EAPI void eina_array_flush (Eina_Array *array);
EAPI void eina_array_remove (Eina_Array *array, Eina_Bool
(*keep)(void *data, void *gdata), void *gdata);
+
+#define EINA_ARRAY_ITER_NEXT(array, index, item) for ((index) = 0, (item) =
_eina_array_get((array), (index)); (index) < (array)->count; ++(index), (item)
= _eina_array_get((array), (index)))
+
+#include "eina_inline_array.x"
#endif
===================================================================
RCS file: /cvs/e/e17/proto/eina/src/include/eina_inline_array.x,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- eina_inline_array.x 30 Jul 2008 16:34:54 -0000 1.1
+++ eina_inline_array.x 1 Aug 2008 12:26:35 -0000 1.2
@@ -11,15 +11,15 @@
_eina_array_grow(Eina_Array *array)
{
void **tmp;
- size_t total;
-
+ unsigned int total;
+
total = array->total + array->step;
tmp = realloc(array->data, sizeof (void*) * total);
- if (!tmp) return 0;
-
+ if (UNLIKELY(!tmp)) return 0;
+
array->total = total;
array->data = tmp;
-
+
return 1;
}
@@ -28,7 +28,7 @@
{
if (UNLIKELY((array->count + array->step) > array->total))
if (!_eina_array_grow(array)) return ;
-
+
array->data[array->count++] = data;
}
@@ -36,6 +36,12 @@
_eina_array_get(Eina_Array *array, unsigned int index)
{
return array->data[index];
+}
+
+static inline unsigned int
+eina_array_count(Eina_Array *array)
+{
+ return array->count;
}
#endif
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs