delete.c
531 Bytes
#include <search.h>
#include <sys/types.h>
#include "hash.h"
#include "interface/hashable.h"
#include "utils/hash.h"
static
inline
int
hashDeleteComp(const void * a, const void * b)
{
return hashableGetHash((void*)b) - *(const unsigned long*)a;
}
void *
hashDelete(Hash this, const char * search, size_t nsearch)
{
unsigned long hash = sdbm((const unsigned char *)search, nsearch);
void * found = tfind(&hash, &(this->root), hashDeleteComp);
return (NULL != found)? *(void**)found : NULL;
}
// vim: set ts=4 sw=4: