How can I find the length of a given GArray?

I have a GArray from GValue (all non-zero) that was allocated at runtime using g_array_append_val. I wonder how I can find out what the index of the last element, or, more precisely, how many elements the array occupies. Code for example

for (length=0;g_value_get_int(&g_array_index(array, GValue, length)); length++); return length 

will fail.

+6
source share
1 answer

This is not like documentation, but the number of elements in the array is stored in the field array->len .

+12
source

All Articles