Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible/practical to use Lua's hash table outside of Lua?

Tags:

c

hashtable

lua

I find myself needing a hash table container in a C project which includes Lua. I am wondering if it is possible to use the hash table in Lua as a generic container. I have looked at ltable.h and all of the functions require a Lua state and seem tied to the Lua environment so I am guessing this is not practical if the data needs to be independent of Lua.

like image 787
Nick Van Brunt Avatar asked Jan 27 '11 19:01

Nick Van Brunt


1 Answers

It is possible and the easiest way is just to use the official C API for Lua. No need to dig into the innards of ltable.h.

like image 100
lhf Avatar answered Sep 29 '22 06:09

lhf