lsquic_hash.h revision 5392f7a3
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_hash.c -- A generic hash 450aadb33SDmitri Tikhonov */ 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#ifndef LSQUIC_HASH_H 750aadb33SDmitri Tikhonov#define LSQUIC_HASH_H 850aadb33SDmitri Tikhonov 950aadb33SDmitri Tikhonovstruct lsquic_hash; 105392f7a3SLiteSpeed Tech 115392f7a3SLiteSpeed Techstruct lsquic_hash_elem 125392f7a3SLiteSpeed Tech{ 135392f7a3SLiteSpeed Tech TAILQ_ENTRY(lsquic_hash_elem) 145392f7a3SLiteSpeed Tech qhe_next_bucket, 155392f7a3SLiteSpeed Tech qhe_next_all; 165392f7a3SLiteSpeed Tech const void *qhe_key_data; 175392f7a3SLiteSpeed Tech void *qhe_value; 185392f7a3SLiteSpeed Tech unsigned qhe_key_len; 195392f7a3SLiteSpeed Tech unsigned qhe_hash_val; 205392f7a3SLiteSpeed Tech enum { 215392f7a3SLiteSpeed Tech QHE_HASHED = 1 << 0, 225392f7a3SLiteSpeed Tech } qhe_flags; 235392f7a3SLiteSpeed Tech}; 2450aadb33SDmitri Tikhonov 2550aadb33SDmitri Tikhonovstruct lsquic_hash * 2650aadb33SDmitri Tikhonovlsquic_hash_create (void); 2750aadb33SDmitri Tikhonov 2850aadb33SDmitri Tikhonovvoid 2950aadb33SDmitri Tikhonovlsquic_hash_destroy (struct lsquic_hash *); 3050aadb33SDmitri Tikhonov 3150aadb33SDmitri Tikhonovstruct lsquic_hash_elem * 3250aadb33SDmitri Tikhonovlsquic_hash_insert (struct lsquic_hash *, const void *key, unsigned key_sz, 335392f7a3SLiteSpeed Tech void *value, struct lsquic_hash_elem *); 3450aadb33SDmitri Tikhonov 3550aadb33SDmitri Tikhonovstruct lsquic_hash_elem * 3650aadb33SDmitri Tikhonovlsquic_hash_find (struct lsquic_hash *, const void *key, unsigned key_sz); 3750aadb33SDmitri Tikhonov 385392f7a3SLiteSpeed Tech#define lsquic_hashelem_getdata(el) ((el)->qhe_value) 3950aadb33SDmitri Tikhonov 4050aadb33SDmitri Tikhonovvoid 4150aadb33SDmitri Tikhonovlsquic_hash_erase (struct lsquic_hash *, struct lsquic_hash_elem *); 4250aadb33SDmitri Tikhonov 4350aadb33SDmitri Tikhonovvoid 4450aadb33SDmitri Tikhonovlsquic_hash_reset_iter (struct lsquic_hash *); 4550aadb33SDmitri Tikhonov 4650aadb33SDmitri Tikhonovstruct lsquic_hash_elem * 4750aadb33SDmitri Tikhonovlsquic_hash_first (struct lsquic_hash *); 4850aadb33SDmitri Tikhonov 4950aadb33SDmitri Tikhonovstruct lsquic_hash_elem * 5050aadb33SDmitri Tikhonovlsquic_hash_next (struct lsquic_hash *); 5150aadb33SDmitri Tikhonov 5250aadb33SDmitri Tikhonovunsigned 5350aadb33SDmitri Tikhonovlsquic_hash_count (struct lsquic_hash *); 5450aadb33SDmitri Tikhonov 55c51ce338SDmitri Tikhonovsize_t 56c51ce338SDmitri Tikhonovlsquic_hash_mem_used (const struct lsquic_hash *); 5750aadb33SDmitri Tikhonov#endif 58