🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
GetMem and FreeMem
how to register these 2 methods to AngelScript since it is returning a pointer to a long ?
//---------------------------------------------------------
long* CObjectScript::GetMemory(long sizeBytes)
{
unsigned char *buffer;
getmem (&buffer, sizeBytes);
return ((long*)buffer);
}
//---------------------------------------------------------
void CObjectScript::FreeMemory(long* buffer)
{
free (buffer);
}
I suggest that you register a new data type to hold pointers like this.
Regards,
Andreas
// Register the object typeengine->RegisterObjectType("ptr", sizeof(void*), asOBJ_PRIMITIVE);// Now register the GetMem and FreeMem to handle that typeengine->RegisterGlobalFunction("ptr GetMem(uint)", asFUNCTION(GetMem), asCALL_CDECL);engine->RegisterGlobalFunction("void FreeMem(ptr)", asFUNCTION(FreeMem), asCALL_CDECL);
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement