Pointer.autorelease readonly



The Pointer.autorelease property controls wether the pointed memory is freed by the Lua garbage collector, are not (the default).

All the C data objects from the C FFI module manages their memory, so the user don't have to take care of freeing the memory pointed to those kind of values.

Example

local crt = c.Library() -- Use the Library instance to define the C function "_strdup()" -- this function takes one arguments of the Z type (const char *) -- and returns a char* value for the duplicated string crt._strdup = "(Z)p" -- Calls the just defined C function, returning a new C Pointer local ptr = crt._strdup("Hello LuaRT") -- Prints the duplicated string print(ptr:as("char*")) -- the _strdup() function returns a pointer that must be freed by the user ptr.autorelease = true