move around - flatter.
[profile/ivi/evas.git] / src / lib / data / evas_inline_array.x
1 #ifndef EVAS_INLINE_ARRAY_H
2 #define EVAS_INLINE_ARRAY_H
3
4 #ifdef __GNUC__
5 # define UNLIKELY(x) __builtin_expect(!!(x), 0)
6 #else
7 # define UNLIKELY(x) (x)
8 #endif
9
10 static inline Evas_Bool
11 _evas_array_grow(Evas_Array *array)
12 {
13    void **tmp;
14    size_t total;
15    
16    total = array->total + array->step;
17    tmp = realloc(array->data, sizeof (void*) * total);
18    if (!tmp) return 0;
19    
20    array->total = total;
21    array->data = tmp;
22    
23    return 1;
24 }
25
26 static inline void
27 _evas_array_append(Evas_Array *array, void *data)
28 {
29    if (UNLIKELY((array->count + array->step) > array->total))
30      if (!_evas_array_grow(array)) return ;
31    
32    array->data[array->count++] = data;
33 }
34
35 static inline void *
36 _evas_array_get(Evas_Array *array, unsigned int index)
37 {
38    return array->data[index];
39 }
40
41 #endif