fix bug in new ptr vector append

This commit is contained in:
Andrew Pamment 2018-10-10 11:12:04 +10:00
parent 5e797ed2c3
commit f70565325e

View File

@ -140,8 +140,8 @@ int ptr_vector_append(struct ptr_vector *vec, void *p) {
vec->capacity *= 2; vec->capacity *= 2;
ps = realloc(vec->ptrs, vec->capacity * sizeof(void *)); ps = realloc(vec->ptrs, vec->capacity * sizeof(void *));
assert(ps != NULL); assert(ps != NULL);
memset(vec->ptrs + oldcap, 0, (vec->capacity - oldcap) * sizeof(void *));
vec->ptrs = ps; vec->ptrs = ps;
memset(vec->ptrs + oldcap, 0, (vec->capacity - oldcap) * sizeof(void *));
} }
vec->ptrs[vec->len] = p; vec->ptrs[vec->len] = p;
++vec->len; ++vec->len;