18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#ifndef DRIZZLED_DYNAMIC_ARRAY_H
22
#define DRIZZLED_DYNAMIC_ARRAY_H
29
typedef struct st_dynamic_array
31
30
unsigned char *buffer;
32
size_t elements,max_element;
33
32
uint32_t alloc_increment;
34
33
uint32_t size_of_element;
35
void push_back(void*);
42
void set_size(size_t v)
37
50
#define my_init_dynamic_array(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
38
51
#define my_init_dynamic_array_ci(A,B,C,D) init_dynamic_array2(A,B,NULL,C,D)
40
extern bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint32_t element_size,
41
void *init_buffer, uint32_t init_alloc,
42
uint32_t alloc_increment);
43
/* init_dynamic_array() function is deprecated */
44
extern bool init_dynamic_array(DYNAMIC_ARRAY *array,uint32_t element_size,
45
uint32_t init_alloc,uint32_t alloc_increment);
46
extern bool insert_dynamic(DYNAMIC_ARRAY *array,unsigned char * element);
47
extern unsigned char *alloc_dynamic(DYNAMIC_ARRAY *array);
48
extern unsigned char *pop_dynamic(DYNAMIC_ARRAY*);
49
extern bool set_dynamic(DYNAMIC_ARRAY *array,unsigned char * element,uint32_t array_index);
50
extern void get_dynamic(DYNAMIC_ARRAY *array,unsigned char * element,uint32_t array_index);
51
extern void delete_dynamic(DYNAMIC_ARRAY *array);
52
extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint32_t array_index);
53
extern void freeze_size(DYNAMIC_ARRAY *array);
54
extern int get_index_dynamic(DYNAMIC_ARRAY *array, unsigned char * element);
55
#define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element)
56
#define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index))
57
#define push_dynamic(A,B) insert_dynamic((A),(B))
58
#define reset_dynamic(array) ((array)->elements= 0)
59
#define sort_dynamic(A,cmp) my_qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp))
53
void init_dynamic_array2(DYNAMIC_ARRAY*, uint32_t element_size, void *init_buffer, uint32_t init_alloc, uint32_t alloc_increment);
54
unsigned char *alloc_dynamic(DYNAMIC_ARRAY *array);
55
unsigned char *pop_dynamic(DYNAMIC_ARRAY*);
56
void delete_dynamic(DYNAMIC_ARRAY *array);
61
58
} /* namespace drizzled */
63
#endif /* DRIZZLED_DYNAMIC_ARRAY_H */