Commit bbc31806 authored by Timo Teräs's avatar Timo Teräs

common: fix apk_array copying, and additional size_t fixes

parent a80cdfe9
......@@ -108,6 +108,7 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size);
static inline void \
array_type_name##_copy(struct array_type_name **a, struct array_type_name *b)\
{ \
if (*a == b) return; \
*a = apk_array_resize(*a, b->num, sizeof(elem_type_name));\
memcpy((*a)->item, b->item, b->num * sizeof(elem_type_name));\
} \
......
......@@ -10,13 +10,15 @@
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include "apk_defines.h"
static int *dummy_array = 0;
void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
{
int old_size, diff;
size_t old_size;
ssize_t diff;
void *tmp;
if (new_size == 0) {
......@@ -25,7 +27,7 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
return &dummy_array;
}
old_size = array ? *((int*) array) : 0;
old_size = array ? *((size_t *) array) : 0;
diff = new_size - old_size;
if (array == &dummy_array)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment