Closed digicannon closed 1 year ago
This is not going to get merged.
Niche platforms and environments are something we can't test reliably and already take up a disproportionate amount of our time. If anything, we're going to support fewer affordances for platforms lacking basic C functionality going forward, not add more of them.
If your platforms' allocator has neither realloc nor a way to figure out the size of an allocation gives it base pointer, there is already an easy way to support it using the existing API: just put a tag value with the size in front in your realloc
implementation. That way, the code that deals with the peculiarities of your platform lives on your side where you can test and debug it. By contrast, if we merged this, 99.9% of stb_ds users (ourselves included) would be on a platform that ignores size_in_use
which means it's only a matter of time until it breaks.
Haha, no, I said by email I'd be ok with this, although it needs to be changed to not break existing code.
Although the only reason I said it would be ok to add it is because I didn't realize there was already an STBDS_REALLOC etc., so I thought size_in_use would be ok to support if we were adding the feature, but I suppose if there already is one I need to reconsider whether it's worth it.
If your platforms' allocator has neither realloc nor a way to figure out the size of an allocation gives it base pointer, there is already an easy way to support it using the existing API: just put a tag value with the size in front in your
realloc
implementation. That way, the code that deals with the peculiarities of your platform lives on your side where you can test and debug it. By contrast, if we merged this, 99.9% of stb_ds users (ourselves included) would be on a platform that ignoressize_in_use
which means it's only a matter of time until it breaks.
I guess this is a good argument, so yeah, nevermind, not going to accept this.
For environments that have
malloc
andfree
but notrealloc
.STBDS_REALLOC
can be implemented with something like this thanks to the addition ofsize_in_use
:Also made the arguments for STBDS_REALLOC/FREE match in the definition and documentation.