X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2Fhashvector.c;h=c26125376e9d811abc67e80e02f0f6cad572dcb5;hb=c08a0975036f23f972a16a07efb0c07113c96d2e;hp=27c2d65e5d63bec9bedbe5f33ff5006599c72873;hpb=c1aae73b1fafd372c4f38a1a205e20a9f22a2fa0;p=rrq%2Frrqmisc.git diff --git a/vector/hashvector.c b/vector/hashvector.c index 27c2d65..c261253 100644 --- a/vector/hashvector.c +++ b/vector/hashvector.c @@ -1,4 +1,5 @@ -#include "hashvector.h" +#include +#include #define SELF hv->type @@ -6,7 +7,7 @@ // to the first of holes encountered while considering collisions. // Returns a pointer to the place for the item, or 0 in case of OOM or // overfull hashvector (i.e. 0 shouldn't happen). -// If itemkey is set, then the itmekey callback function is used for +// If itemkey is set, then the itemkey callback function is used for // obtaining a temporary key from the item. static void **hashvector_find_slot( hashvector *hv, void *key, unsigned long *i, int itemkey ) @@ -174,3 +175,19 @@ unsigned long hashvector_hashcode(unsigned char *key,unsigned long n) { return value; } + +hashvector *hashvector_create(int variant,itemkeyfun *type) { + hashvector *hv = (hashvector*) malloc( sizeof( hashvector ) ); + (*hv) = (hashvector) { + .table = (vector) { + .variant = variant, + .size = 0, + .entries = 0 + }, + .fill = 0, + .holes = 0, + .type = type + }; + return hv; +} +