Core
Memory Management and Core Types
Core memory and container usage in NAppGUI is macro-heavy but consistent. The heap API provides typed allocation helpers, while arrays and other containers expose a generic implementation wrapped in type-safe macros.
Relevant Source Files
Heap API
heap.h exposes both raw and typed allocation helpers. At the low level there are named allocation functions such as
heap_malloc_imp, heap_calloc_imp, aligned variants, reallocation, and explicit free. At the common call-site level,
the macros are the real interface: heap_new, heap_new0, heap_new_n, heap_realloc_n,
heap_delete, and heap_delete_n.
The layer also includes verbosity, stats, leak detection, and auditor helpers, which is why the header describes it as an allocator and auditor, not just a malloc wrapper.
Typed Containers
ArrPt is the pointer-array family and ArrSt is the value-array family. Both are implemented as generic arrays underneath,
but the public macros make the call sites type-aware: create, destroy, clear, insert, append, delete, sort, search, read/write, and iteration.
The iteration macros are worth noting because they shape a lot of the codebase style. Patterns like arrpt_foreach(...),
arrst_foreach(...), and the matching arrpt_end()/arrst_end() appear throughout gui,
osgui, and core.
Containers As DBind Types
A subtle but important part of core.cpp is that it registers ArrPt and ArrSt as DBind container types during
core_start(). That is what allows DBind-backed serialization and comparison logic to treat these containers as first-class typed values.
The runtime differentiates between pointer-storing and value-storing containers, which matches the public split between ArrPt and ArrSt.
Practical Style of The Codebase
The project consistently prefers small C structs plus typed macro wrappers over templates or code generation. You see this not just in arrays, but also in sets, strings, object handles, and many internal helper patterns.
If you are reading or extending the codebase, it helps to treat these macros as the intended language of the project rather than as mere convenience wrappers.