28 lines
521 B
C
28 lines
521 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef _ht_H_
|
|
#define _ht_H_
|
|
|
|
#include <kernel/common.h>
|
|
|
|
typedef struct ht_entry {
|
|
char *key;
|
|
union {
|
|
void *ptr;
|
|
u64 val;
|
|
};
|
|
struct ht_entry *next;
|
|
} ht_entry_t;
|
|
|
|
typedef struct {
|
|
ht_entry_t **buckets;
|
|
size_t capacity;
|
|
size_t size;
|
|
} ht_t;
|
|
|
|
ht_t *ht_create(size_t capacity);
|
|
void ht_destroy(ht_t *ht);
|
|
int ht_insert(ht_t *ht, const char *key, void *value);
|
|
void *ht_lookup(ht_t *ht, const char *key);
|
|
int ht_delete(ht_t *ht, const char *key);
|
|
|
|
#endif /* _ht_H_ */
|