Jump to content
  • Advertisement
Sign in to follow this  
iram

GetMem and FreeMem

This topic is 4581 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
Advertisement
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

so now i just do this in the script:


ptr Test = GetMem(1000);

FreeMem(Test);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!