[英]How can I find the length of a given GArray?
I have a GArray of GValue (all non-zero) which has been allocated at runtime with g_array_append_val. 我有一个Grray的GValue(全部为非零),它已在运行时使用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. 会因为出界而失败。
它似乎没有详细记录,但数组中元素的数量存储在字段array->len
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.