40 lines
777 B
C
40 lines
777 B
C
/* SPDX-License-Identifier: MIT */
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#define rb_size_t size_t
|
|
#include "ringbuf.h"
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
struct RingBuf rb;
|
|
rb_init(&rb, 10, malloc, sizeof(int));
|
|
|
|
int data[] = { 5, 6, 7, 8 };
|
|
printf("Address at data first element: %p\n", &data[0]);
|
|
printf("Address at internal first element: %p\n", &rb.buffer);
|
|
// rb_push(&rb, data, 4, memcpy);
|
|
rb_push_back(&rb, data, memcpy);
|
|
|
|
// Print addresses of data
|
|
for(int i = 0; i < 4; i++) {
|
|
printf("Address: %u\n", &data[i]);
|
|
}
|
|
|
|
print_seq(data, 4);
|
|
print_seq(rb.buffer, 4);
|
|
|
|
int dest[5];
|
|
// rb_read(&rb, (void *)dest, 5);
|
|
|
|
// for (int i = 0; i < 5; i++) {
|
|
// printf("Data: %d\n", dest[i]);
|
|
// }
|
|
|
|
rb_destroy(&rb, free);
|
|
|
|
return 0;
|
|
}
|