36
37
* an opaque data structure that represents the dynamic array.
38
typedef struct _DynamicArray DynamicArray;
39
typedef struct DynamicArray DynamicArray;
41
43
* Represents a for each function.
43
45
* @param self the dynamic array.
44
46
* @param data the data to be passed to the each iteration.
45
* @returns data to be put in a new DynamicArray, if used with
46
* dynamic_array_for_each_with_return.
47
* @returns data to be put in a new \c DynamicArray, if used with
48
* <tt>dynamic_array_for_each_with_return</tt>.
48
50
typedef void * (* ForEachFunc)(DynamicArray * self, void * item, void * data);
53
* Represents a function to be used when freeing some item in a dynamic array.
55
* @param obj The object to be freed.
57
typedef void * (* FreeFunc)(void * obj);
59
#endif /* __H_DEFS__ */
52
62
* Create a new dynamic array.
54
64
* @param len The length of the initial array.
55
* @param item_size The size of the items to be stored.
65
* @param free_func The function to be used when freeing the items. Can be \c NULL.
66
* If free_func is NULL, it will use the standard library's
69
* Normally a function with the signature <tt> (DynamicArray * self,
70
void * item, void * data) </tt> should be used but cast to FreeFunc.
57
DynamicArray * dynamic_array_new (size_t len);
72
DynamicArray * dynamic_array_new (size_t len, FreeFunc free_func);
60
75
* Frees the dynamic array.