Skip to content

Get rid of size parameter in memFree() ? #260

@tehKaiN

Description

@tehKaiN

So I was thinking...

memFree() requires passing size since OS' FreeMem() requires it, but that could be solved by allocating 4 bytes more in front and storing the space there, and let the free function auto-handle it.

This would lead to a bit of waste of the memory (assuming most games don't do more than 1k allocations, it would be at most 4k of RAM). On the other hand, those values are already in the program code (be it constants or calculated) and sometimes they are also kept in structs so that they know how to deallocate themselves. On the other hand, deallocations of same memory chunks in a loop might be more efficient in its current state, because the size would have to be retrieved only once for repeated chunks. That doesn't seem to match most allocation scenarios, though.

This also would be needed for #23, so if the answer is no, then that issue needs to be closed too.

This came to me as I read this thread on EAB that lead me to this post at StackOverflow.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions