pico-sdk icon indicating copy to clipboard operation
pico-sdk copied to clipboard

#1670 adding static queue methods

Open daveythacher opened this issue 2 years ago • 5 comments

Adding static_queue_init and static_queue_init_spinlock. These accept a pointer to a static storage array. This allows using the queue API without calloc. Added null checks to queue logic also.

No testing performed.

daveythacher avatar Mar 18 '24 12:03 daveythacher

Looks ok. We might want to protect queue_free so it does nothing if it memory was not allocated on the heap? And maybe add an example, although you can leave that to us.

peterharperuk avatar Mar 18 '24 14:03 peterharperuk

Queue free is a good point. Part of me wants to create a new type which forces a duplication of the API. Part of me says we could add a field to the queue structure. Overall I think we could point out in the documentation or example that queue free is not required for static queues. This is ambiguous, which can be problematic.

daveythacher avatar Mar 18 '24 15:03 daveythacher

It might be possible to assert the memory is in the heap? But you can leave queue_free as it is for now.

peterharperuk avatar Mar 18 '24 15:03 peterharperuk

Any objections to removing the heap completely? (Probably more of a question for version 2.0 of the SDK.)

daveythacher avatar Mar 21 '24 16:03 daveythacher

I think as much as we'd like to remove stuff we don't like, we're stuck with it for the time being.

peterharperuk avatar Mar 22 '24 10:03 peterharperuk