X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=tests%2Fexample-hashvector.c;h=516cd07393cc8e790e6b872a32453e767e18e7b2;hb=c1aae73b1fafd372c4f38a1a205e20a9f22a2fa0;hp=7bd57a5f53a3018aa7a101b501553d64db30919b;hpb=475928381654054e66270d48001c1a9b6e4258b6;p=rrq%2Frrqmisc.git diff --git a/tests/example-hashvector.c b/tests/example-hashvector.c index 7bd57a5..516cd07 100644 --- a/tests/example-hashvector.c +++ b/tests/example-hashvector.c @@ -8,15 +8,15 @@ typedef struct _ipslot { unsigned int bits; } ipslot; -static unsigned long voidp_hashcode(void *key) { +static unsigned long voidp_hashcode(itemkeyfun *this,void *key) { return hashvector_hashcode( key, sizeof( ipslot ) ); } -static void* voidp_itemkey(void *item) { +static void* voidp_itemkey(itemkeyfun *this,void *item) { return item; } -static int voidp_haskey(void *item,void *key) { +static int voidp_haskey(itemkeyfun *this,void *item,void *key) { return memcmp( item, key, sizeof( ipslot ) ) == 0; } @@ -33,13 +33,16 @@ static int shrink(vector *pv,unsigned long index,void *item,void *data) { } int main(int argc,char **argv) { + itemkeyfun voidpfun = { + .hashcode = voidp_hashcode, + .itemkey = voidp_itemkey, + .haskey = voidp_haskey + }; hashvector hv = { .table = { 4, 0 }, .fill = 0, .holes = 0, - .keyhashcode = voidp_hashcode, - .itemkey = voidp_itemkey, - .haskey = voidp_haskey + .type = &voidpfun }; int i = 0; for ( ; i < 259; i++ ) {