Sign in to follow this  

GetMem and FreeMem

This topic is 4299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

This topic is 4299 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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