MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_ringbuffer_create

Function rt_ringbuffer_create

components/drivers/ipc/ringbuffer.c:425–449  ·  view source on GitHub ↗

* @brief Create a ring buffer object with a given size. * * @param size The size of the buffer in bytes. * * @return Return a pointer to ring buffer object. When the return value is RT_NULL, it means this creation failed. */

Source from the content-addressed store, hash-verified

423 * @return Return a pointer to ring buffer object. When the return value is RT_NULL, it means this creation failed.
424 */
425struct rt_ringbuffer *rt_ringbuffer_create(rt_uint32_t size)
426{
427 struct rt_ringbuffer *rb;
428 rt_uint8_t *pool;
429
430 RT_ASSERT(size > 0);
431
432 size = RT_ALIGN_DOWN(size, RT_ALIGN_SIZE);
433
434 rb = (struct rt_ringbuffer *)rt_malloc(sizeof(struct rt_ringbuffer));
435 if (rb == RT_NULL)
436 goto exit;
437
438 pool = (rt_uint8_t *)rt_malloc(size);
439 if (pool == RT_NULL)
440 {
441 rt_free(rb);
442 rb = RT_NULL;
443 goto exit;
444 }
445 rt_ringbuffer_init(rb, pool, size);
446
447exit:
448 return rb;
449}
450RTM_EXPORT(rt_ringbuffer_create);
451
452/**

Callers 11

rt_serial_bypass_initFunction · 0.85
rt_inputcapture_openFunction · 0.85
pipe_fops_openFunction · 0.85
rt_pipe_openFunction · 0.85
ulog_rawFunction · 0.85
at_cli_initFunction · 0.85
client_cli_parserFunction · 0.85
uart_msg_initFunction · 0.85
ringbuffer_exampleFunction · 0.85
ringbuffer_force_exampleFunction · 0.85
ringbuffer_sampleFunction · 0.85

Calls 3

rt_mallocFunction · 0.85
rt_freeFunction · 0.85
rt_ringbuffer_initFunction · 0.85

Tested by 3

ringbuffer_exampleFunction · 0.68
ringbuffer_force_exampleFunction · 0.68
ringbuffer_sampleFunction · 0.68