OpenBSD manual page server

Manual Page Search Parameters

OHASH_INTERVAL(3) Library Functions Manual OHASH_INTERVAL(3)

ohash_interval, ohash_create_entry, ohash_qlookup, ohash_qlookupihelper functions for open hashing

#include <stdint.h>
#include <stddef.h>
#include <ohash.h>

ohash_interval(const char *start, const char **pend);

void *
ohash_create_entry(struct ohash_info *info, const char *start, const char **pend);

unsigned int
ohash_qlookupi(struct ohash *h, const char *start, const char **pend);

unsigned int
ohash_qlookup(struct ohash *h, const char *start);

These functions are commonly used to simplify open hashing usage, and use similar conventions. They operate indifferently on NUL-terminated strings (by setting *pend = NULL) or memory ranges (delimited by start and *pend). For NUL-terminated strings, as a side effect, those functions set *pend to the terminating NUL byte.

() is a simple hashing function that yields good results on common data sets.

() can be used to create a new record with a given key. In that case, the alloc field of info should point to a malloc(3)-like function to allocate the storage:

p = (*info->alloc)(sz, info->data);

() is a wrapper function that simply calls ohash_interval() and ().

() is a variation on ohash_qlookupi() designed for NUL-terminated strings.


Those functions are completely non-standard and should be avoided in portable programs.

Those functions were designed and written for OpenBSD make(1) by Marc Espie in 1999.

May 12, 2014 OpenBSD-6.2