lua-users home
lua-l archive

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


Quoth Florian Weimer <fw@deneb.enyo.de>, on 2010-05-09 18:55:19 +0200:
> I haven't tried this for real yet, but I plan to use a custom userdata
> with a __gc meta-method which invokes an embedded clean-up callback.
>
> Your example would then become:
> 
>     char const *const str = some_library_get_string();
>     clair_push_cleanup(L, some_library_free_string, str);

Are you doing or planning to do something like using lua_cpcall,
shoving the extra userdata into the registry, and then stashing the
integer key for it somewhere?  I assume you're handling the case where
lua_newuserdata fails.  (Unless you mean you're just using a
preallocated userdata, in which case I don't know how you intend to
get __gc to be called at a suitable time.)

   ---> Drake Wilson