Reputation: 177
This struct is supposed to have the infos for each item of a queue.
struct tx_queue_item_t {
//user input
uint8_t priority;
uint8_t attempts;
uint8_t *buff;
size_t size;
uint32_t timeout; //10ms base
//system input
uint8_t idNum;
uint8_t attemptCount;
uint32_t tickCountAtTx; //to check for receive timeout
enum tx_queue_status_t status;
};
I would like to know if I'm able to have 'temporary items' (temporary structs), which free their own memory usage when such item of the queue be considered as done/processed.
Is there a way to make this in C? malloc
?
Consider that I also want to access the values of variables by their names for each struct instance.
And also in order I can know what is the total memory being used for such purpose (create temporary items).
Regards.
Upvotes: 0
Views: 237
Reputation: 15586
No. C does not have widely-implemented garbage collectors. You can use an external library like boehm-gc, but that may not be what you want.
The most portable solution would be to use malloc
and free
manually, or use a function to create and destroy your structure.
Upvotes: 3