23RCSID(
"$Id: 06e453ce1a72b99e5b8da080893a40017cb7c1bf $")
25#include <freeradius-devel/io/ring_buffer.h>
26#include <freeradius-devel/util/debug.h>
27#include <freeradius-devel/util/hash.h>
28#include <freeradius-devel/util/syserror.h>
29#include <freeradius-devel/util/talloc.h>
37#define ARRAY_SIZE (4 * ALLOC_SIZE)
113 fprintf(stderr,
"usage: ring_buffer_test [OPTS]\n");
114 fprintf(stderr,
" -x Debugging mode.\n");
115 fprintf(stderr,
" -s <string> Set random seed to <string>.\n");
116 fprintf(stderr,
" -l <length> Set the iteration number to <length>.\n");
121int main(
int argc,
char *argv[])
125 int i, start, end, length = 1000;
131 while ((c = getopt(argc, argv,
"hl:s:x")) != -1)
switch (c) {
133 length = strtol(optarg, NULL, 10);
149 argc -= (optind - 1);
150 argv += (optind - 1);
155 fprintf(stderr,
"Failed creating ring buffer\n");
171 for (i = 0; i < length; i++) {
static TALLOC_CTX * autofree
#define NEVER_RETURNS
Should be placed before the function return type.
#define fr_cond_assert(_x)
Calls panic_action ifndef NDEBUG, else logs error and evaluates to value of _x.
#define fr_exit_now(_x)
Exit without calling atexit() handlers, producing a log message in debug builds.
uint32_t fr_hash_update(void const *data, size_t size, uint32_t hash)
fr_ring_buffer_t * fr_ring_buffer_create(TALLOC_CTX *ctx, size_t size)
Create a ring buffer.
uint8_t * fr_ring_buffer_alloc(fr_ring_buffer_t *rb, size_t size)
Mark data as allocated.
uint8_t * fr_ring_buffer_reserve(fr_ring_buffer_t *rb, size_t size)
Reserve room in the ring buffer.
int fr_ring_buffer_free(fr_ring_buffer_t *rb, size_t size_to_free)
Mark data as free,.
size_t fr_ring_buffer_used(fr_ring_buffer_t *rb)
Get the amount of data used in a ring buffer.
int main(int argc, char *argv[])
static uint8_t * data[ARRAY_SIZE]
static void free_blocks(fr_ring_buffer_t *rb, UNUSED uint32_t *seed, int *start, int *end)
static size_t array[ARRAY_SIZE]
static size_t seed_string_len
static char const * seed_string
static NEVER_RETURNS void usage(void)
static void alloc_blocks(fr_ring_buffer_t *rb, uint32_t *seed, UNUSED int *start, int *end)
static unsigned int hash(char const *username, unsigned int tablesize)
#define talloc_autofree_context
The original function is deprecated, so replace it with our version.