base: use uintptr_t for hash type
Use uintptr_t for hash type; this is consistent with CoreFoundation, which uses 32-bit integers on 32-bit platforms for the hash code, and 64-bit integers on 64-bit platforms. (libheimbase is modelled on CoreFoundation.) Previously we used unsigned long, which would have the same behavior on LP32/LP64 systems, but not on Windows (where unsigned long is 32-bits on 64-bit platforms).
This commit is contained in:
@@ -61,7 +61,7 @@ data_cmp(void *a, void *b)
|
||||
return memcmp(osa->data, osb->data, osa->length);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
data_hash(void *ptr)
|
||||
{
|
||||
heim_octet_string *os = ptr;
|
||||
|
@@ -149,7 +149,7 @@ heim_dict_get_type_id(void)
|
||||
static struct hashentry *
|
||||
_search(heim_dict_t dict, heim_object_t ptr)
|
||||
{
|
||||
unsigned long v = heim_get_hash(ptr);
|
||||
uintptr_t v = heim_get_hash(ptr);
|
||||
struct hashentry *p;
|
||||
|
||||
for (p = dict->tab[v % dict->size]; p != NULL; p = p->next)
|
||||
@@ -219,7 +219,7 @@ heim_dict_set_value(heim_dict_t dict, heim_object_t key, heim_object_t value)
|
||||
heim_release(h->value);
|
||||
h->value = heim_retain(value);
|
||||
} else {
|
||||
unsigned long v;
|
||||
uintptr_t v;
|
||||
|
||||
h = malloc(sizeof(*h));
|
||||
if (h == NULL)
|
||||
|
@@ -58,7 +58,7 @@ error_cmp(void *a, void *b)
|
||||
return heim_cmp(ap->msg, bp->msg);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
error_hash(void *ptr)
|
||||
{
|
||||
struct heim_error *p = ptr;
|
||||
|
@@ -210,13 +210,13 @@ heim_get_tid(heim_object_t ptr)
|
||||
* @return a hash value
|
||||
*/
|
||||
|
||||
unsigned long
|
||||
uintptr_t
|
||||
heim_get_hash(heim_object_t ptr)
|
||||
{
|
||||
heim_type_t isa = _heim_get_isa(ptr);
|
||||
if (isa->hash)
|
||||
return isa->hash(ptr);
|
||||
return (unsigned long)ptr;
|
||||
return (uintptr_t)ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -609,10 +609,10 @@ autorel_cmp(void *a, void *b)
|
||||
return (a == b);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
autorel_hash(void *ptr)
|
||||
{
|
||||
return (unsigned long)ptr;
|
||||
return (uintptr_t)ptr;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -184,7 +184,7 @@ heim_get_tid(heim_object_t object);
|
||||
int
|
||||
heim_cmp(heim_object_t a, heim_object_t b);
|
||||
|
||||
unsigned long
|
||||
uintptr_t
|
||||
heim_get_hash(heim_object_t ptr);
|
||||
|
||||
void
|
||||
|
@@ -42,7 +42,7 @@
|
||||
typedef void (*heim_type_init)(void *);
|
||||
typedef heim_object_t (*heim_type_copy)(void *);
|
||||
typedef int (*heim_type_cmp)(void *, void *);
|
||||
typedef unsigned long (*heim_type_hash)(void *);
|
||||
typedef uintptr_t (*heim_type_hash)(void *);
|
||||
typedef heim_string_t (*heim_type_description)(void *);
|
||||
|
||||
typedef struct heim_type_data *heim_type_t;
|
||||
|
@@ -58,12 +58,12 @@ number_cmp(void *a, void *b)
|
||||
return na - nb;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
number_hash(void *ptr)
|
||||
{
|
||||
if (heim_base_is_tagged_object(ptr))
|
||||
return heim_base_tagged_object_value(ptr);
|
||||
return (unsigned long)*(int *)ptr;
|
||||
return (uintptr_t)*(int64_t *)ptr;
|
||||
}
|
||||
|
||||
struct heim_type_data _heim_number_object = {
|
||||
|
@@ -73,11 +73,11 @@ string_cmp(void *a, void *b)
|
||||
return strcmp(a, b);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
string_hash(void *ptr)
|
||||
{
|
||||
const char *s = ptr;
|
||||
unsigned long n;
|
||||
uintptr_t n;
|
||||
|
||||
for (n = 0; *s; ++s)
|
||||
n += *s;
|
||||
|
Reference in New Issue
Block a user