X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fexample-hashvector.c;h=28eaeab3473f3b2d996d4d170ddd4c04a83c9393;hb=74eec6f62db4459232f95b5d39069b9b4ceeb830;hp=8fe73b6ad4f53397bf95e30427fec2f2bbe73ccd;hpb=9e8fceb62721997ca62abfed6080e917bb429eee;p=rrq%2Frrqmisc.git 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 },