Implement free_sized and free_aligned_sized (C23).

In some implementations, these functions could potentially be faster than free() and/or perform additional safety checks, but this implementation just ignores the extra arguments.
This commit is contained in:
Stephen Heumann committed 2025-11-13 20:45:51 -06:00
1 parent 0f88d093f2
commit 7f1241c588
1 file changed
+46
+46
View File
@@ -499,6 +499,52 @@ quick_exit start
brl ~C_QUIT
end
****************************************************************
*
* void free_aligned_sized(void *ptr, size_t alignment, size_t size);
*
* Free an allocation from aligned_alloc, given the pointer
* and the requested alignment and allocation size.
*
****************************************************************
*
free_aligned_sized start
pla remove alignment and size from stack
sta 7,s
pla
sta 7,s
plx
pla
xba
sta 6,s
txa
sta 5,s
jml free call free
end
****************************************************************
*
* void free_sized(void *ptr, size_t size);
*
* Free an allocation, given the pointer and allocation size.
*
****************************************************************
*
free_sized start
lda 6,s remove size from stack
sta 10,s
plx
ply
pla
sta 3,s
pla
phy
phx
jml free call free
end
****************************************************************
*
* char *getenv(const char *name)