Lines Matching full:value_array
57 * @value_array: #GValueArray to get a value from
60 * Return a pointer to the value at @index_ containd in @value_array.
62 * Returns: pointer to a value at @index_ in @value_array
65 g_value_array_get_nth (GValueArray *value_array,
68 g_return_val_if_fail (value_array != NULL, NULL);
69 g_return_val_if_fail (index < value_array->n_values, NULL);
71 return value_array->values + index;
75 value_array_grow (GValueArray *value_array,
79 g_return_if_fail (n_values >= value_array->n_values);
81 value_array->n_values = n_values;
82 if (value_array->n_values > value_array->n_prealloced)
84 guint i = value_array->n_prealloced;
86 value_array->n_prealloced = (value_array->n_values + GROUP_N_VALUES - 1) & ~(GROUP_N_VALUES - 1);
87 value_array->values = g_renew (GValue, value_array->values, value_array->n_prealloced);
89 i = value_array->n_values;
90 memset (value_array->values + i, 0,
91 (value_array->n_prealloced - i) * sizeof (value_array->values[0]));
96 value_array_shrink (GValueArray *value_array)
99 if (value_array->n_prealloced >= value_array->n_values + GROUP_N_VALUES)
101 value_array->n_prealloced = (value_array->n_values + GROUP_N_VALUES - 1) & ~(GROUP_N_VALUES - 1);
102 value_array->values = g_renew (GValue, value_array->values, value_array->n_prealloced);
120 GValueArray *value_array = g_slice_new (GValueArray);
122 value_array->n_values = 0;
123 value_array->n_prealloced = 0;
124 value_array->values = NULL;
125 value_array_grow (value_array, n_prealloced, TRUE);
126 value_array->n_values = 0;
128 return value_array;
133 * @value_array: #GValueArray to free
138 g_value_array_free (GValueArray *value_array)
142 g_return_if_fail (value_array != NULL);
144 for (i = 0; i < value_array->n_values; i++)
146 GValue *value = value_array->values + i;
151 g_free (value_array->values);
152 g_slice_free (GValueArray, value_array);
157 * @value_array: #GValueArray to copy
165 g_value_array_copy (const GValueArray *value_array)
170 g_return_val_if_fail (value_array != NULL, NULL);
176 value_array_grow (new_array, value_array->n_values, TRUE);
178 if (G_VALUE_TYPE (value_array->values + i) != 0)
182 g_value_init (value, G_VALUE_TYPE (value_array->values + i));
183 g_value_copy (value_array->values + i, value);
190 * @value_array: #GValueArray to add an element to
193 * Insert a copy of @value as first element of @value_array.
195 * Returns: the #GValueArray passed in as @value_array
198 g_value_array_prepend (GValueArray *value_array,
201 g_return_val_if_fail (value_array != NULL, NULL);
203 return g_value_array_insert (value_array, 0, value);
208 * @value_array: #GValueArray to add an element to
211 * Insert a copy of @value as last element of @value_array.
213 * Returns: the #GValueArray passed in as @value_array
216 g_value_array_append (GValueArray *value_array,
219 g_return_val_if_fail (value_array != NULL, NULL);
221 return g_value_array_insert (value_array, value_array->n_values, value);
226 * @value_array: #GValueArray to add an element to
227 * @index_: insertion position, must be <= value_array->n_values
230 * Insert a copy of @value at specified position into @value_array.
232 * Returns: the #GValueArray passed in as @value_array
235 g_value_array_insert (GValueArray *value_array,
241 g_return_val_if_fail (value_array != NULL, NULL);
242 g_return_val_if_fail (index <= value_array->n_values, value_array);
246 i = value_array->n_values;
247 value_array_grow (value_array, value_array->n_values + 1, FALSE);
248 if (index + 1 < value_array->n_values)
249 g_memmove (value_array->values + index + 1, value_array->values + index,
250 (i - index) * sizeof (value_array->values[0]));
251 memset (value_array->values + index, 0, sizeof (value_array->values[0]));
254 g_value_init (value_array->values + index, G_VALUE_TYPE (value));
255 g_value_copy (value, value_array->values + index);
257 return value_array;
262 * @value_array: #GValueArray to remove an element from
263 * @index_: position of value to remove, must be < value_array->n_values
265 * Remove the value at position @index_ from @value_array.
267 * Returns: the #GValueArray passed in as @value_array
270 g_value_array_remove (GValueArray *value_array,
273 g_return_val_if_fail (value_array != NULL, NULL);
274 g_return_val_if_fail (index < value_array->n_values, value_array);
276 if (G_VALUE_TYPE (value_array->values + index) != 0)
277 g_value_unset (value_array->values + index);
278 value_array->n_values--;
279 if (index < value_array->n_values)
280 g_memmove (value_array->values + index, value_array->values + index + 1,
281 (value_array->n_values - index) * sizeof (value_array->values[0]));
282 value_array_shrink (value_array);
283 if (value_array->n_prealloced > value_array->n_values)
284 memset (value_array->values + value_array->n_values, 0, sizeof (value_array->values[0]));
286 return value_array;
291 * @value_array: #GValueArray to sort
294 * Sort @value_array using @compare_func to compare the elements accoring to
299 * Returns: the #GValueArray passed in as @value_array
302 g_value_array_sort (GValueArray *value_array,
307 if (value_array->n_values)
308 qsort (value_array->values,
309 value_array->n_values,
310 sizeof (value_array->values[0]),
312 return value_array;
317 * @value_array: #GValueArray to sort
321 * Sort @value_array using @compare_func to compare the elements accoring
326 * Returns: the #GValueArray passed in as @value_array
329 g_value_array_sort_with_data (GValueArray *value_array,
333 g_return_val_if_fail (value_array != NULL, NULL);
336 if (value_array->n_values)
337 g_qsort_with_data (value_array->values,
338 value_array->n_values,
339 sizeof (value_array->values[0]),
341 return value_array;