Sign in to follow this  
iram

GetMem and FreeMem

Recommended Posts

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); }

Share this post


Link to post
Share on other sites
I suggest that you register a new data type to hold pointers like this.


// Register the object type
engine->RegisterObjectType("ptr", sizeof(void*), asOBJ_PRIMITIVE);

// Now register the GetMem and FreeMem to handle that type
engine->RegisterGlobalFunction("ptr GetMem(uint)", asFUNCTION(GetMem), asCALL_CDECL);
engine->RegisterGlobalFunction("void FreeMem(ptr)", asFUNCTION(FreeMem), asCALL_CDECL);


Regards,
Andreas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this