From 8d1178788a203e032b8ab10ce4ec7059bc18d203 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 20 Jul 2017 21:58:51 -0700 Subject: [PATCH] Update libds. --- external/libds | 2 +- include/pairmap.h | 6 +++--- src/pairmap.c | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/external/libds b/external/libds index cd822fe..1d037dd 160000 --- a/external/libds +++ b/external/libds @@ -1 +1 @@ -Subproject commit cd822fedfc1357919b6cba46a9b61e58e2fc1dde +Subproject commit 1d037dd31e4a242518e2f562d8d2c980443a1869 diff --git a/include/pairmap.h b/include/pairmap.h index 50f5d8c..019e8ec 100644 --- a/include/pairmap.h +++ b/include/pairmap.h @@ -36,20 +36,20 @@ typedef struct pairmap_key_s pairmap_key; * @param key the key for the hash table. * @return the resulting hash. */ -unsigned long pairmap_hash_func(void* key); +unsigned long pairmap_hash_func(const void* key); /** * Compares two pairmap_key's. * @param a the first pairmap_key * @param b the second pairmap_key * @return */ -int pairmap_cmp_func(void* a, void* b); +int pairmap_cmp_func(const void* a, const void* b); /** * Copies a pairmap_key. * @param key the key to copy. * @return the copy of the key. */ -void* pairmap_copy_func(void* key); +void* pairmap_copy_func(const void* key); /** * Initializes a hash table with functions used for pair maps. * @param ht the hash table to initialize. diff --git a/src/pairmap.c b/src/pairmap.c index 2745573..32d429e 100644 --- a/src/pairmap.c +++ b/src/pairmap.c @@ -1,19 +1,19 @@ #include "pairmap.h" #include -unsigned long pairmap_hash_func(void* key){ - pairmap_key* new_key = key; +unsigned long pairmap_hash_func(const void* key){ + const pairmap_key* new_key = key; unsigned int hash = 0; hash |= ((new_key->x & 0xffff) << 8) + (new_key->y & 0xffff); return hash; } -int pairmap_cmp_func(void* a, void* b){ - pairmap_key* new_key_a = a; - pairmap_key* new_key_b = b; +int pairmap_cmp_func(const void* a, const void* b){ + const pairmap_key* new_key_a = a; + const pairmap_key* new_key_b = b; return (new_key_a->x == new_key_b->x) && (new_key_a->y == new_key_b->y); } -void* pairmap_copy_func(void* key){ - pairmap_key* copy_from = key; +void* pairmap_copy_func(const void* key){ + const pairmap_key* copy_from = key; pairmap_key* new_key = malloc(sizeof(*new_key)); if(new_key){ new_key->x = copy_from->x;