Compare commits
No commits in common. "06b949bed46dd5a596b10b5de5beb62770e7f258" and "6022bdee9245200bcad638298a4f14483bce7fa4" have entirely different histories.
06b949bed4
...
6022bdee92
2 changed files with 15 additions and 3 deletions
4
driver.c
4
driver.c
|
@ -16,9 +16,7 @@ main(void)
|
||||||
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
|
||||||
int ok = WriteOk; // Assume we can write
|
int ok = WriteOk; // Assume we can write
|
||||||
if(rb_push_many(&rb, arr, memcpy, 8) != WriteOk) {
|
ok = rb_push_many(&rb, arr, memcpy, 8);
|
||||||
printf("Failed to write data to buffer...\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int d;
|
int d;
|
||||||
while(rb_pop_front(&rb, &d, memcpy) == ReadOk) {
|
while(rb_pop_front(&rb, &d, memcpy) == ReadOk) {
|
||||||
|
|
14
ringbuf.c
14
ringbuf.c
|
@ -23,6 +23,20 @@ rb_init(struct RingBuf *rb, rb_size_t capacity, ALLOC_T malloc_fn,
|
||||||
rb->count = 0;
|
rb->count = 0;
|
||||||
rb->write_head = rb->buffer;
|
rb->write_head = rb->buffer;
|
||||||
rb->read_head = rb->buffer;
|
rb->read_head = rb->buffer;
|
||||||
|
|
||||||
|
DEBUG_PRINT("Reading from buffer at position %d\n",
|
||||||
|
rb->capacity * rb->struct_size);
|
||||||
|
|
||||||
|
// Read from buffer at max position to force a segfault if theres an issue
|
||||||
|
void *top = rb->buffer + (rb->capacity * rb->struct_size);
|
||||||
|
|
||||||
|
DEBUG_PRINT("Buffer top successfully read at virtual address: %p\n", &top);
|
||||||
|
|
||||||
|
DEBUG_PRINT(
|
||||||
|
"Initialized ring buffer. Capacit: %d, struct_size: %d, total: %d\n",
|
||||||
|
rb->capacity, rb->struct_size, rb->capacity * rb->struct_size);
|
||||||
|
|
||||||
|
DEBUG_PRINT("Size of RB: %lu\n", sizeof(struct RingBuf));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue