Debian Codegraph @

include/utils/vector.h

raw
1 #ifndef VECTOR_H
2 #define VECTOR_H
3
4 #include <stddef.h>
5 #include <stdint.h>
6
7 // A vector store statement ordered by code_nr
8 // A vector stores statement_t ptr ordered by text_nr
9
10 // code_nr and text_nr both starts from 1
11 // statement at index 0 should be ignored
12
13 // eof_lines won't be in the vector
14
15 typedef struct
16 {
17 uint32_t count;
18 uint32_t capacity;
19 size_t elem_size;
20 void *data;
21 } vector_t;
22
23 extern void *reallocate (void *p, size_t new_size);
24
25 // set initial_capcity to 0 to let vector grow itself
26 extern void init_vector (vector_t *v, size_t elem_size,
27 size_t initial_capcity);
28
29 extern void free_vector (vector_t *v);
30
31 extern void *push_vector (vector_t *v, void *elem);
32
33 extern void *get_vector (vector_t *v, uint32_t idx);
34
35 #endif