Skip to content

Instantly share code, notes, and snippets.

@pervognsen pervognsen/coll.h
Last active Dec 23, 2019

Embed
What would you like to do?
// 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
You can’t perform that action at this time.