You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
803 B

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <list.h>
#include <unistd.h>
#include <internal/crc.h>
#include <hashtable.h>
int32_t _h_getid(void* key, unsigned long* sum, size_t keysize, size_t blocksize)
{
return (int32_t)((*sum = _h_crc32(0xffffffffu, key, keysize)) % blocksize);
}
hashtable_t* h_create(size_t keytype, size_t valuetype, size_t blocksize)
{
hashtable_t* proto = (hashtable_t*)malloc(sizeof(hashtable_t));
proto->back = l_create(sizeof(struct _h_kvpair_t)+keytype+valuetype, blocksize);
proto->keysize = keytype;
return proto;
}
void h_add(hashtable_t* hash, void* key, void* value)
{
unsigned long crc32;
int32_t id = _h_getid(key, &crc32, hash->keysize, hash->back->blocksize);
//TODO: search through blocks as pages for empty id match
}