MCPcopy Create free account
hub / github.com/codr7/hacktical-c / hc_vector_grow

Function hc_vector_grow

vector/vector.c:27–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27void hc_vector_grow(struct hc_vector *v, const size_t capacity) {
28 v->capacity = capacity;
29 size_t size = v->item_size * (v->capacity+1);
30 uint8_t *new_start = hc_acquire(v->malloc, size);
31
32 if (v->start) {
33 memmove(new_start, v->start, v->length * v->item_size);
34 hc_release(v->malloc, v->start);
35 }
36
37 v->start = new_start;
38 v->end = v->start + v->item_size*v->length;
39}
40
41void hc_vector_clear(struct hc_vector *v) {
42 v->length = 0;

Callers 2

growFunction · 0.85
hc_vector_insertFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected