🎉 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

Started by
2 comments, last by WitchLord 18 years, 3 months ago
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); }
Advertisement
I suggest that you register a new data type to hold pointers like this.

// 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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game


so now i just do this in the script:


ptr Test = GetMem(1000);

FreeMem(Test);
Exactly! [smile]

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement