Hello,
currently some C API functions allocate memory and require the user to free that memory (e.g. moveWithCollisions
).
It would be nice to have a version of these functions that accept a buffer+size from the user and return the amount of items that were filled in the buffer.
Something like this:
// Returns the number of collisions happened
int playdate->sprite->moveWithCollisionsNoAlloc(LCDSprite *sprite, float goalX, float goalY, float *actualX, float *actualY, int *len, SpriteCollisionInfo **outCollisions, int outCollisionsCapacity);
This would allow the developer to have complete control over how the memory is allocated and freed (e.g. by using a scratch buffer/stack allocator/etc) and would avoid having to allocate/deallocate memory through the system allocator after the game initialization.
As a bonus, it would also avoid certain pitfalls that are pretty easy to fall into if you're not experience with the Playdate API.
Cheers!