From 0d56f67ed1e486f09201a038fbdfefa01ef702fc Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 30 Sep 2014 23:26:32 +0200 Subject: [PATCH] Fixes tommyds implementation for x64. --- tommyds/tommyarray.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tommyds/tommyarray.c b/tommyds/tommyarray.c index b46879c2..944a672d 100644 --- a/tommyds/tommyarray.c +++ b/tommyds/tommyarray.c @@ -27,6 +27,8 @@ #include "tommyarray.h" +#include /* for ptrdiff_t */ + /******************************************************************************/ /* array */ @@ -69,7 +71,8 @@ void tommy_array_grow(tommy_array* array, unsigned size) segment = tommy_cast(void**, tommy_calloc(array->bucket_max, sizeof(void*))); /* store it adjusting the offset */ - array->bucket[array->bucket_mac] = &segment[-array->bucket_max]; + /* cast to ptrdiff_t to ensure to get a negative value */ + array->bucket[array->bucket_mac] = &segment[-(ptrdiff_t)array->bucket_max]; ++array->bucket_mac; ++array->bucket_bit;