From: Ralph Ronnquist Date: Sun, 10 Jul 2022 21:10:59 +0000 (+1000) Subject: upgrade for hashvector ABI changes. X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=74eec6f62db4459232f95b5d39069b9b4ceeb830;p=rrq%2Frrqmisc.git upgrade for hashvector ABI changes. --- diff --git a/tests/example-hashvector.c b/tests/example-hashvector.c index 8fe73b6..28eaeab 100644 --- a/tests/example-hashvector.c +++ b/tests/example-hashvector.c @@ -8,19 +8,23 @@ typedef struct _ipslot { unsigned int bits; } ipslot; -static unsigned long voidp_hashcode(itemkeyfun *this,void *key) { +static unsigned long voidp_hashcode(void *this,void *key) { return hashvector_hashcode( key, sizeof( ipslot ) ); } -static void* voidp_itemkey(itemkeyfun *this,void *item) { +static void* voidp_itemkey(void *this,void *item) { return item; } -static int voidp_haskey(itemkeyfun *this,void *item,void *key) { +static int voidp_haskey(void *this,void *item,void *key) { return memcmp( item, key, sizeof( ipslot ) ) == 0; } -static void voidp_releasekey(itemkeyfun *this,void *key) { +static void voidp_releasekey(void *this,void *key) { +} + +static int voidp_tostring(void *this, void *item, char *buffer, int limit) { + return snprintf( buffer, limit, "%p", item ); } static int shrink(vector *pv,unsigned long index,void *item,void *data) { @@ -40,7 +44,8 @@ int main(int argc,char **argv) { .hashcode = voidp_hashcode, .itemkey = voidp_itemkey, .haskey = voidp_haskey, - .releasekey = voidp_releasekey + .releasekey = voidp_releasekey, + .tostring = voidp_tostring }; hashvector hv = { .table = { 1, 4, 0 },