luabind and returning a char*
Hi! What would be the correct way of allocating a string when you have to return it in a lua function when using luabind eg.
// function that will be exported to lua using luabind
const char* f(float id)
{
char* buffer = new char[100];
sprintf(buffer,"ID = %.0f",id);
return buffer;
}
This would be a memory leak if "buffer" doesn't get deallocated.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement