rb_array_size(3)
bofc manual pages
rb_array_size(3)
NAME
rb_array_size - gets number of elements from given array
SYNOPSIS
DESCRIPTION
This simple macro can be used to quickly calculate number of elements needed by rb_write(3) or rb_read(3) functions from array.
Let's analyze int arr[8] array. Calling rb function like this: rb_read(rb, arr, sizeof(arr)) is invalid, as rb will try to copy (assuming int is 4 bytes long) 4 * 8 = 32 elements, and that would cause out of boud write to arr. Instead you need to pass number of elements array contains. Now, you could hold define somewhere with array size - or you could use this macro to calculate it like that rb_read(rb, arr, rb_array_size(arr)) and that will return correct number of elements - 8.
This works only on arrays, don't even think about passing pointer!
RETURN VALUES
Number of elements of a array during compile time. This cannot fail.SEE ALSO
rb_overview(7), rb_new(3), rb_init(3), rb_destroy(3), rb_cleanup(3), rb_discard(3), rb_stop(3), rb_stop_signal(3), rb_read(3), rb_recv(3), rb_write(3), rb_send(3), rb_posix_read(3), rb_posix_recv(3), rb_posix_write(3), rb_posix_send(3), rb_clear(3), rb_count(3), rb_space(3), rb_header_size(3), rb_version(3)
23 October 2018 (v1.1.0)
rb_array_size(3)