smol_world
sc
smol_world | sc | |
---|---|---|
3 | 17 | |
80 | 2,173 | |
- | - | |
1.5 | 6.3 | |
about 1 year ago | about 2 months ago | |
C++ | C | |
Apache License 2.0 | BSD 3-clause "New" or "Revised" License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
smol_world
-
A simple hash table in C
Thank you for this article.
I have been working on trying to design a contiguous hash table data structure that has these two mutual requirements:
a) allows deep clones (due to contiguous memory copyable with memcpy)
b) supports arbitrarily nestable hashmaps
The closest library I know about is smolworld ( https://github.com/snej/smol_world ) but I don't know how easy it can be cloned.
These requirements rules out multiple mallocs: I do one single malloc and expect that to be enough for the entire hashmap.
I'm not sure if these constraints might also force a fixed number of buckets and a fixed capacity.
The clonable property requires interior mutability be limited, because if you memcpy pointers they would cause structure sharing, that I'm trying to avoid, hence a deep clone.
Rationale: these are the use cases I have for such a data structure. The first is cheap copy on write. I also have a left-right concurrency hashmap, but I feel the properties of this data structure are even better. The first is a sharding in multithreading design: do a cheap memcpy for each thread and shard the processing and merge at the end, without any synchronization cost while the threads are working. I know that deep cloning is slow in Java if you do it with loops rather than memcpy. Another use case is efficient serialization.
- Smol_world: Compact garbage-collected heap and JSON-like object model
sc
- A simple hash table in C
- Advice for bigger c projects?
- sc - Common libraries and data structures for C
-
Hacker News top posts: May 17, 2022
Common libraries and data structures for C\ (107 comments)
-
Common libraries and data structures for C
Can someone tell me what is this line from sc_signal.c:247 in sc/signal/
If the way it is used requires the user to break the abstraction/encapsulation and manually buffer some fields in order not to break the data structure and leak memory, I would call that a bug.
There is one use of sc_array_clear() in the test code [1] which really makes it look as if it is being used in a way that I think (again, I haven't single-stepped this code, only read it) leaks memory.
I agree on the pain of everything being macros, it's more pain than it's worth I think and will likely lead to code duplication (and more pain in debugging, probably).
I would even go so far as to think that this kind of single-file design, where each file is independent of the others, makes it harder and more annoying to implement more complicated data structures.
[1]: https://github.com/tezc/sc/blob/master/array/array_test.c#L3...
-
Uthash – C macros for hash tables and more
https://github.com/tezc/sc/tree/master/map
For those who are interested in faster hashmaps, I tried bunch of hashmaps and this one performs better than others. This is for C. Maybe C++ has better hashmaps.
What are some alternatives?
uthash - C macros for hash tables and more
frr - The FRRouting Protocol Suite
Klib - A standalone and lightweight C library
wazero - wazero: the zero dependency WebAssembly runtime for Go developers
QEMU - Official QEMU mirror. Please see https://www.qemu.org/contribute/ for how to submit changes to QEMU. Pull Requests are ignored. Please only use release tarballs from the QEMU website.
chibicc - A small C compiler
ctl - My variant of the C Template Library
stage0 - A set of minimal dependency bootstrap binaries
swiss-table - C adaptation of the swiss table (flat hash map) presented at CppCon by Google (https://www.youtube.com/watch?v=ncHmEUmJZf4).
pottery - Pottery - A container and algorithm template library in C
gcc
libderp - C collections. Easy to build, boring algorithms. Dumb is good.