public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
fd26ea2872b3b29df7a0342e44fe7acb4192eec8 blob 1516 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
/*
 * Copyright (C) 2024 olang maintainers
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#ifndef MAP_H
#define MAP_H

#include "arena.h"

#include <stdbool.h>
#include <stdint.h>
#include <string.h>

#define MAP_INITIAL_CAPACITY 32

#define U32_FNV1A_PRIME 0x01000193
#define U32_FNV1A_OFFSET_BASIS 0x811c9dc5

typedef struct map map_t;
typedef struct map_bucket map_bucket_t;
typedef struct map_entry map_entry_t;

typedef struct map {
    arena_t *arena;
    map_entry_t *entries;
    size_t capacity;
    size_t size;
} map_t;

typedef struct map_kv {
    char *key;
    void *value;
} map_kv_t;

typedef struct map_entry {
    char *key;
    void *value;
    uint32_t hash;
    map_entry_t *next;
} map_entry_t;

map_t *
map_new(arena_t *arena);

bool
map_put(map_t *map, char *key, void *value);

void *
map_get(map_t *map, char *key);

void
map_get_kvs(map_t *map, map_kv_t **kvs);

#endif /* MAP_H */
debug log:

solving fd26ea2 ...
found fd26ea2 in http://lists.johnnyrichard.com/olang/20241010013318.222905-3-carlos@maniero.me/
found 6f8681c in https://git.johnnyrichard.com/olang.git
preparing index
index prepared:
100644 6f8681ccc17a16be165e738819ad68587eaee6cf	src/map.h

applying [1/1] http://lists.johnnyrichard.com/olang/20241010013318.222905-3-carlos@maniero.me/
diff --git a/src/map.h b/src/map.h
index 6f8681c..fd26ea2 100644

Checking patch src/map.h...
Applied patch src/map.h cleanly.

index at:
100644 fd26ea2872b3b29df7a0342e44fe7acb4192eec8	src/map.h

Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox