7
typedef struct ib_vector_struct ib_vector_t;
9
/* An automatically resizing vector datatype with the following properties:
11
-Contains void* items.
13
-The items are owned by the caller.
15
-All memory allocation is done through a heap owned by the caller, who is
16
responsible for freeing it when done with the vector.
18
-When the vector is resized, the old memory area is left allocated since it
19
uses the same heap as the new memory area, so this is best used for
20
relatively small or short-lived uses.
23
/********************************************************************
24
Create a new vector with the given initial size. */
30
mem_heap_t* heap, /* in: heap */
31
ulint size); /* in: initial size */
33
/********************************************************************
34
Push a new element to the vector, increasing its size if necessary. */
39
ib_vector_t* vec, /* in: vector */
40
void* elem); /* in: data element */
42
/********************************************************************
43
Get the number of elements in the vector. */
48
/* out: number of elements in vector */
49
ib_vector_t* vec); /* in: vector */
51
/********************************************************************
52
Get the n'th element. */
57
/* out: n'th element */
58
ib_vector_t* vec, /* in: vector */
59
ulint n); /* in: element index to get */
61
/* See comment at beginning of file. */
62
struct ib_vector_struct {
63
mem_heap_t* heap; /* heap */
64
void** data; /* data elements */
65
ulint used; /* number of elements currently used */
66
ulint total; /* number of elements allocated */