php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
shs.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Alexander Borisov
3 *
4 * Author: Alexander Borisov <borisov@lexbor.com>
5 */
6
7#ifndef LEXBOR_SHS_H
8#define LEXBOR_SHS_H
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <string.h>
15
16#include "lexbor/core/base.h"
17
18
19typedef struct {
20 char *key;
21 void *value;
22
23 size_t key_len;
24 size_t next;
25}
27
28typedef struct {
29 uint32_t key;
30 uint32_t value;
31
32 uint32_t next;
33}
35
36
39 const lxb_char_t *key, size_t size);
40
43 const lxb_char_t *key, size_t key_len);
44
47 const lxb_char_t *key, size_t key_len);
48
49/*
50 * Inline functions
51 */
54 const size_t table_size, const uint32_t key)
55{
56 const lexbor_shs_hash_t *entry;
57
58 entry = &table[ (key % table_size) + 1 ];
59
60 do {
61 if (entry->key == key) {
62 return entry;
63 }
64
65 entry = &table[entry->next];
66 }
67 while (entry != table);
68
69 return NULL;
70}
71
72
73#ifdef __cplusplus
74} /* extern "C" */
75#endif
76
77#endif /* LEXBOR_SHS_H */
78
79
80
81
82
#define LXB_API
Definition def.h:48
new_type size
Definition ffi.c:4365
#define NULL
Definition gdcache.h:45
unsigned char key[REFLECTION_KEY_LEN]
LXB_API const lexbor_shs_entry_t * lexbor_shs_entry_get_lower_static(const lexbor_shs_entry_t *root, const lxb_char_t *key, size_t key_len)
Definition shs.c:63
LXB_API const lexbor_shs_entry_t * lexbor_shs_entry_get_upper_static(const lexbor_shs_entry_t *root, const lxb_char_t *key, size_t key_len)
Definition shs.c:92
lxb_inline const lexbor_shs_hash_t * lexbor_shs_hash_get_static(const lexbor_shs_hash_t *table, const size_t table_size, const uint32_t key)
Definition shs.h:53
LXB_API const lexbor_shs_entry_t * lexbor_shs_entry_get_static(const lexbor_shs_entry_t *tree, const lxb_char_t *key, size_t size)
Definition shs.c:34
Definition shs.h:19
size_t next
Definition shs.h:24
void * value
Definition shs.h:21
size_t key_len
Definition shs.h:23
char * key
Definition shs.h:20
uint32_t value
Definition shs.h:30
uint32_t key
Definition shs.h:29
uint32_t next
Definition shs.h:32
#define lxb_inline
Definition types.h:21
unsigned char lxb_char_t
Definition types.h:27