Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active December 23, 2019 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pervognsen/d754ab6729f8393307e15cba19f7b452 to your computer and use it in GitHub Desktop.
Save pervognsen/d754ab6729f8393307e15cba19f7b452 to your computer and use it in GitHub Desktop.
// 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