Last active
December 23, 2019 04:08
-
-
Save pervognsen/d754ab6729f8393307e15cba19f7b452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stretchy buffer, works directly on typed c pointers | |
afree(a) | |
apush(a, x) | |
alen(a) // lvalue, so you can do things like a[i] = a[--alen(a)] | |
aend(a) // a + alen(a) | |
areserve(a, n) | |
aresize(a, n) | |
// uint64 -> uint64 hash table | |
hinit(h, n) | |
hfree(h) | |
hput(h, k, v) // casts k and v to void * | |
hget(h, k) // return void * | |
hgetu(h, k) // return uint64 | |
hgeti(h, k) // return int64 | |
// global string table. pattern: read external string into temp buffer, sintern to get stable pointer, then use pointer hash | |
sintern(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment