[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Why is there no API to realloc a full userdata?
- From: Reuben Thomas <rrt@...>
- Date: Mon, 11 Jun 2012 23:45:27 +0100
Why is there no C API to realloc a full userdata? Is it just not
common enough a need?
My use case: I am making alien (the Lua FFI extension) buffers be
reallocable. I would like to be able to say simply:
lua_reallocuserdata(L, ud, nsize)
Without this I have to box a pointer in a full userdata (to get
garbage collection) and then duplicate the code to keep track of a
memory block and (so that I can use the Lua state's allocator) its
size. Furthermore, any time I want to use a userdata I need to
consider whether to use the usual lua_touserdata to get its "raw"
address, or whether to use alien_touserdata, which unboxes
alien-created boxed userdata.
Searching the list archives, I can see others discussing the "boxed
pointer" technique, but nothing about why there's no C API for it, nor
anything about the extra step of keeping track of the block's size.
--
http://rrt.sc3d.org