Circular Buffer Push
Implement rb_push for a fixed-size circular buffer.
Return: * 1 on success * 0 if the buffer is full
This models how UART drivers store incoming bytes.
Input: A ring buffer and a value to push. Output: 1 if inserted, 0 if full.
Constraints
- No dynamic memory.
- Constant-time operation.
- Do not overwrite existing data.
1#define SIZE 42 3typedef struct {4 int data[SIZE];5 int head;6 int count;7} Ring;8 9int rb_push(Ring *r, int v) {10 // Implement11 return 0;12}