Add hashvector_create + some polishing
[rrq/rrqmisc.git] / vector / hashvector.c
index 0f5b31f6e640f9281bf982a9ca8fea422bd073d7..c26125376e9d811abc67e80e02f0f6cad572dcb5 100644 (file)
@@ -1,4 +1,5 @@
-#include "hashvector.h"
+#include <stdlib.h>
+#include <hashvector.h>
 
 #define SELF hv->type
 
@@ -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;
+}
+