7
/********************************************************************
8
Create a new vector with the given initial size. */
14
mem_heap_t* heap, /* in: heap */
15
ulint size) /* in: initial size */
21
vec = mem_heap_alloc(heap, sizeof(*vec));
24
vec->data = mem_heap_alloc(heap, sizeof(void*) * size);
31
/********************************************************************
32
Push a new element to the vector, increasing its size if necessary. */
37
ib_vector_t* vec, /* in: vector */
38
void* elem) /* in: data element */
40
if (vec->used >= vec->total) {
42
ulint new_total = vec->total * 2;
44
new_data = mem_heap_alloc(vec->heap,
45
sizeof(void*) * new_total);
46
memcpy(new_data, vec->data, sizeof(void*) * vec->total);
49
vec->total = new_total;
52
vec->data[vec->used] = elem;