alliedmodders / sourcemod

SourceMod - Source Engine Scripting and Administration
http://www.sourcemod.net/
972 stars 420 forks source link

Adding natives for working with memory #1337

Open vanz666 opened 4 years ago

vanz666 commented 4 years ago

It would be nice to add natives for working with memory, such as malloc, realloc, free. This is useful for passing parameters when calling SDKCall, which are pointers to an object or structure in memory. It is also useful for working with game data structures like CUtlVector, etc. And so that you can specify the type of memory allocator in the parameters of the natives (g_pMemAlloc or standard), since the data structures of many Source games use exactly g_pMemAlloc.

KyleSanderson commented 3 years ago

The memory allocator is an implementation detail (also congrats for opening issue 1337). As you've skipped the issue template (why?) you've left out the entire context for why this should land. Is this a real issue? Can you try to fill out the template?

nosoop commented 3 years ago

For what it's worth, two extensions already exist for this purpose: SM-Memory and Source Scramble.

I recall asherkin finding a few other cases where having malloc would be good to have, but that was prior to those two extensions being written.