21 #ifndef __CCL_ARRAY_H__
22 # define __CCL_ARRAY_H__
32 # define CCL_ARRAY(_t_) \
41 # define ccl_array_init(_a_) \
42 ccl_array_init_with_size(_a_, 0)
48 # define ccl_array_init_with_size(_a_,_sz_) \
50 (_a_).size = 0; (_a_).data = NULL; \
51 ccl_array_ensure_size (_a_, _sz_); \
58 # define ccl_array_add(_a_,_el_) \
60 ccl_array_ensure_size (_a_, (_a_).size + 1); \
61 (_a_).data[(_a_).size-1] = _el_; \
69 # define ccl_array_delete(_a_) ccl_array_delete_array ((_a_).data)
70 # define ccl_array_clean_and_delete(_a_,_del_) \
72 while ((_a_).size--) _del_ ((_a_).data[(_a_).size]); \
73 ccl_array_delete ((_a_)); \
80 # define ccl_array_ensure_size(_a_,_sz_) \
81 if ((_sz_) >= (_a_).size) \
82 ccl_array_resize(&(_a_).size, sizeof ((_a_).data[0]), \
83 (void **) &((_a_).data), \
89 # define ccl_array_ensure_size_plus_one(_a_) \
90 ccl_array_ensure_size (_a_, (_a_).size + 1)
95 # define ccl_array_trim(_a_,_sz_) \
96 ccl_array_resize (&(_a_).size, sizeof ((_a_).data[0]), \
97 (void **) &((_a_).data), \
103 # define ccl_array_trim_to_size(_a_) ccl_array_trim (_a_, (_a_).size)
106 ccl_array_resize (
int *poldsz,
int elsz,
void **data,
int newsz,
int trim);
CCL_DECLARE_DELETE_PROC(ccl_array_delete_array)
Deletes the memory allocated for a. Objects stored into the array are not deleted.
Some useful and common macros.