I have a GArray of GValue (all non-zero) which has been allocated at runtime with g_array_append_val. I wonder how can I find out what's the index of the last element, or more precisely how many elements does the array hold. Code like
for (length=0;g_value_get_int(&g_array_index(array, GValue, length)); length++);
return length
would fail with an out of bounds.
It doesn't seem to be well-documented, but the number of the elements in the array is stored in the field array->len
.
It's described here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With