MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / CircularBuffer_New

Function CircularBuffer_New

src/util/circular_buffer.c:28–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26};
27
28CircularBuffer CircularBuffer_New
29(
30 size_t item_size, // size of item in bytes
31 uint cap // max number of items in buffer
32) {
33 CircularBuffer cb = rm_calloc(1, sizeof(_CircularBuffer) + item_size * cap);
34
35 cb->read = cb->data; // read from beginning of data
36 cb->write = 0; // write to beginning of data
37 cb->item_cap = cap; // buffer capacity
38 cb->item_size = item_size; // item size
39 cb->item_count = 0; // no items in buffer
40 cb->end_marker = cb->data + (item_size * cap);
41
42 return cb;
43}
44
45// returns number of items in buffer
46uint64_t CircularBuffer_ItemCount

Callers 7

QueriesLog_NewFunction · 0.85
Indexer_InitFunction · 0.85
test_CircularBufferInitFunction · 0.85
test_CircularBuffer_freeFunction · 0.85

Calls 1

rm_callocFunction · 0.85

Tested by 5

test_CircularBufferInitFunction · 0.68
test_CircularBuffer_freeFunction · 0.68