lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


In message 
<CAB5CAC=kYyfE0Xc=yizGUQ8WfvkRfOO+=93ZYiD6gCEY20z4NA@mail.gmail.com> 
you wrote:

> It seems to be a good start.
> What bothers me is the condition to decide what can be collected or not.
> If your code just allocates chunks, perform a local work with it and
> then free it, alloca function could also work, at a much lower cost...
> If, as I imagine, a chunk must be kept until some other other chunk is
> used, it becomes more complicated. You will need to keep references in
> Lua (for example with a table in the registry, where the keys are
> lightuserdata) in the some way as in C++ the destructors are usually
> chained. This can not be done be simply changing calloc in your
> library.

Thanks. The library is for manipulating objects of varying sizes.
Those manipulations may involve the use of temporary objects whose 
storage can be reclaimed anytime. The "permanent" objects are
to be accessed from Lua (how permanent depends on the Lua side of
things), and the exported functions that manipulate them are to 
be wrapped in Lua clothes. 
Everything can be garbage collectible apart from the single
struct allocated when the library is initialised. For that a
plain malloc should be OK. 
I do not think "alloca" is part of ANSI C is it? I have to keep
everything ANSI.

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/