The diff a is little bit messy because I moved a lot of stuff around, but here is the gist of it:
all the macros are overridable (they're defined only if not already defined), and there is a system to include you own config header at the beginning of the file to override what you want
all the platform specific bits are now wrapped inside a macro (all the #ifdef WIN32/GNUC in the main code are gone)
all the macros are documented (at least a little bit)
This was a lot harder to do than I expected 😅, especially the parts with the virtual memory functions. But I'm pretty happy with the result, it should be very easy to port to new platforms now.
The main macros are: LTALLOC_VMALLOC, LTALLOC_VMFREE, and LTALLOC_VMALLOC_MIN_SIZE.
If the plaform supports it, there are two more macros that you can define:
LTALLOC_VMSIZE, which is meant to return size of a previous virtual mem allocation (if not available, eg. on Linux, ltalloc will store the sizes of the allocations internally in a ptrie).
LTALLOC_VMALLOC_ALIGNED, which allocates virtual memory with a specific alignment (Windows/Linux don't have a function for that, but some consoles do), and if not available, ltalloc has a slower method to make sure LTALLOC_VMALLOC end up returning a pointer with the right alignment.
The diff a is little bit messy because I moved a lot of stuff around, but here is the gist of it:
#ifdef WIN32/GNUC
in the main code are gone)This was a lot harder to do than I expected 😅, especially the parts with the virtual memory functions. But I'm pretty happy with the result, it should be very easy to port to new platforms now.
The main macros are:
LTALLOC_VMALLOC
,LTALLOC_VMFREE
, andLTALLOC_VMALLOC_MIN_SIZE
. If the plaform supports it, there are two more macros that you can define:LTALLOC_VMSIZE
, which is meant to return size of a previous virtual mem allocation (if not available, eg. on Linux, ltalloc will store the sizes of the allocations internally in a ptrie).LTALLOC_VMALLOC_ALIGNED
, which allocates virtual memory with a specific alignment (Windows/Linux don't have a function for that, but some consoles do), and if not available, ltalloc has a slower method to make sureLTALLOC_VMALLOC
end up returning a pointer with the right alignment.