-
Book Overview & Buying
-
Table Of Contents
Hands-On RTOS with Microcontrollers - Second Edition
By :
Since the data-type of a queue is arbitrary, we also have the ability to pass data by reference instead of by value. This works in a way that is similar to passing arguments by reference to a function.
The next example-program is in mainQueueCompositePassByReference.c. It is very similar to the prior example-program. However, instead of using queue items which are structs, it uses queue items that are pointers to structs.
A queue will make a copy of whatever data it is holding. So, if the data-structure being queued is large, it can be inefficient to pass the data-structure by value:
When large data structures need to be queued, passing the queue items by reference can be a good idea. Here’s an example of a larger...