In the current configuration, free()ing the memory is left to the user, but very little warning is given
manual free() is not a common pattern within the Arduino Ecosystem. Most things are either static, or RAII-allocated as part of C++ classes.
addDescriptor() always returns a pointer, and doesn't tell the user if that pointer was heap-allocated or part of the static _descriptor structure. This would make a correct user implementation very difficult.
In threaded/tasked systems, multiple tasks may try to memalign() concurrently. I don't have faith the built-in malloc() is thread-safe.
malloc() time is non-deterministic
Even on the largest SAMD51, the entire SRAM could be moved with only 4 descriptors. I think applications with involving that much data would be rare, and the #define override would allow easy adjustment.
memalign()
is deprecatedfree()
ing the memory is left to the user, but very little warning is givenfree()
is not a common pattern within the Arduino Ecosystem. Most things are either static, or RAII-allocated as part of C++ classes.addDescriptor()
always returns a pointer, and doesn't tell the user if that pointer was heap-allocated or part of the static_descriptor
structure. This would make a correct user implementation very difficult.memalign()
concurrently. I don't have faith the built-in malloc() is thread-safe.malloc()
time is non-deterministic#define
override would allow easy adjustment.