summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-20 16:07:47 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-20 16:13:20 +0200
commit78a372464b3dabb1a84279fe5fde9542bd2431f3 (patch)
tree7b80a70a9c59a94de04838e57d717941078cd58f /src/common.c
parent51999c97dabf9fbbe352ca3ead02851a982fcade (diff)
downloadapk-tools-78a372464b3dabb1a84279fe5fde9542bd2431f3.tar.gz
apk-tools-78a372464b3dabb1a84279fe5fde9542bd2431f3.tar.bz2
apk-tools-78a372464b3dabb1a84279fe5fde9542bd2431f3.tar.xz
apk-tools-78a372464b3dabb1a84279fe5fde9542bd2431f3.zip
all: fix array size data type on 64 bit
The array struct aligned size to 64 bit on x86_64 which caused bad things to happen. We use size_t to make sure the size element is correct regardless arch. Solution found by Timo.
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c
index 725f1c4..5e6e793 100644
--- a/src/common.c
+++ b/src/common.c
@@ -31,11 +31,11 @@ void *apk_array_resize(void *array, size_t new_size, size_t elem_size)
if (array == &dummy_array)
array = NULL;
- tmp = realloc(array, sizeof(int) + new_size * elem_size);
+ tmp = realloc(array, sizeof(size_t) + new_size * elem_size);
if (diff > 0)
- memset(tmp + sizeof(int) + old_size * elem_size, 0,
+ memset(tmp + sizeof(size_t) + old_size * elem_size, 0,
diff * elem_size);
- *((int*) tmp) = new_size;
+ *((size_t*) tmp) = new_size;
return tmp;
}