Skip to content

Add some allocation-related attributes - #458

Open
capitalistspz wants to merge 6 commits into
devkitPro:masterfrom
capitalistspz:alloc-attrs
Open

Add some allocation-related attributes#458
capitalistspz wants to merge 6 commits into
devkitPro:masterfrom
capitalistspz:alloc-attrs

Conversation

@capitalistspz

@capitalistspz capitalistspz commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

WUT_ALLOC_SIZE enables checks validating allocation sizes for the allocation result type, and should (but doesn't currently seem to) check out of bounds accesses.

WUT_FREED_BY enables checks for pointers being freed by the wrong function.

WUT_ALLOC_ALIGNED and WUT_MALLOC should enable some optimisations, though the attribute does nothing with negative alignment values (which can be provided to the MEMAllocFrom*Heap functions).

WUT_ALLOC_SIZE isn't applied to MEMAllocFromExpHeapEx because MEMResizeForMBlockExpHeap can change the allocation size.

A few functions had to be swapped around because WUT_FREED_BY needs the free function to be declared first.

`WUT_ALLOC_SIZE` was left off `MEMAllocFromExpHeapEx` because the allocated region may be resized via `MEMResizeForMBlockExpHeap`, but is always accessed via the same pointer.

Some functions had to have the free and allocate function order swapped because the two-parameter `malloc` attribute relies on declaration order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant