Question: data structures in C Question 7 - LIFO Buffers A LIFO Data Buffer (Last-In-First-Out) is a buffer that adds and removes items to and from
data structures in C

Question 7 - LIFO Buffers A LIFO Data Buffer (Last-In-First-Out) is a buffer that adds and removes items to and from the end (A commonly used LIFO is the Stack). Below is a LIFO data structure definition. typedef struct LIFO Buf_tt volatile uintl6 t * head; volatile uint32_ t length; volatile uint32 t num items; uint16_t buffer // Pointer to last added item // Max Num of items in buffer // Current item count in buffer // Pointer to items in heap LIFO_Buf; [Question 7.1] Assume you need to dynamically create many LIFO Data Buffers including the structure definition itself. You write a function, CreateBuf, which returns a pointer to a LIFO buffer structure. Given the LIFO buffer definition above and the declaration for CreateBuf below, write the CreateBuf function definition. The entire structure and the buffer item memory should be declared on the heap. Assume the items buffer portion of the LIFO buffer needs to be 100 items long and this function initializes all members. LIFOBuf * CreateBuf (size_ t buffer_size); [Question 7.2] Using the LIFO structure above, write the implementation of the LIFO_Add_ltem which will add one 16 bit item to the structure at the end. If the LIFO is full, it should just return without doing anything. The function declaration is given below. void LIFO_Add_Item (LIFO Buf * buf, uint16_t data); Question 7 - LIFO Buffers A LIFO Data Buffer (Last-In-First-Out) is a buffer that adds and removes items to and from the end (A commonly used LIFO is the Stack). Below is a LIFO data structure definition. typedef struct LIFO Buf_tt volatile uintl6 t * head; volatile uint32_ t length; volatile uint32 t num items; uint16_t buffer // Pointer to last added item // Max Num of items in buffer // Current item count in buffer // Pointer to items in heap LIFO_Buf; [Question 7.1] Assume you need to dynamically create many LIFO Data Buffers including the structure definition itself. You write a function, CreateBuf, which returns a pointer to a LIFO buffer structure. Given the LIFO buffer definition above and the declaration for CreateBuf below, write the CreateBuf function definition. The entire structure and the buffer item memory should be declared on the heap. Assume the items buffer portion of the LIFO buffer needs to be 100 items long and this function initializes all members. LIFOBuf * CreateBuf (size_ t buffer_size); [Question 7.2] Using the LIFO structure above, write the implementation of the LIFO_Add_ltem which will add one 16 bit item to the structure at the end. If the LIFO is full, it should just return without doing anything. The function declaration is given below. void LIFO_Add_Item (LIFO Buf * buf, uint16_t data)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
