[utils] Adding _copy and _new_copy methods to vectors (the former copies data to a pre-allocated vector, the latter allocates a new vector)

This commit is contained in:
Al
2015-09-06 20:46:29 -07:00
parent 49fe504201
commit 9d2ca08fc2
3 changed files with 43 additions and 43 deletions

View File

@@ -10,13 +10,6 @@
__VECTOR_BASE(name, type) \
__VECTOR_DESTROY(name, type) \
\
static inline name *name##_copy(name *vector, size_t n) { \
name *cpy = name##_new_size(n); \
memcpy(vector->a, cpy->a, n * sizeof(type)); \
cpy->n = n; \
return cpy; \
} \
\
static inline void type##_array_set(type *array, size_t n, type value) { \
for (int i = 0; i < n; i++) { \
array[i] = value; \