Ejemplo n.º 1
0
/**
 * g_value_array_copy:
 * @value_array: #GValueArray to copy
 *
 * Construct an exact copy of a #GValueArray by duplicating all its
 * contents.
 *
 * Returns: (transfer full): Newly allocated copy of #GValueArray
 */
GValueArray*
g_value_array_copy (const GValueArray *value_array)
{
  GValueArray *new_array;
  guint i;

  g_return_val_if_fail (value_array != NULL, NULL);

  new_array = g_slice_new (GValueArray);
#ifdef GSTREAMER_LITE
  if (new_array == NULL) {
    return NULL;
  }
#endif // GSTREAMER_LITE
  new_array->n_values = 0;
  new_array->values = NULL;
  new_array->n_prealloced = 0;
  value_array_grow (new_array, value_array->n_values, TRUE);
  for (i = 0; i < new_array->n_values; i++)
    if (G_VALUE_TYPE (value_array->values + i) != 0)
      {
    GValue *value = new_array->values + i;

    g_value_init (value, G_VALUE_TYPE (value_array->values + i));
    g_value_copy (value_array->values + i, value);
      }
  return new_array;
}
Ejemplo n.º 2
0
/**
 * g_value_array_new:
 * @n_prealloced: number of values to preallocate space for
 *
 * Allocate and initialize a new #GValueArray, optionally preserve space
 * for @n_prealloced elements. New arrays always contain 0 elements,
 * regardless of the value of @n_prealloced.
 *
 * Returns: a newly allocated #GValueArray with 0 values
 *
 * Deprecated: 2.32: Use #GArray and g_array_sized_new() instead.
 */
GValueArray*
g_value_array_new (guint n_prealloced)
{
  GValueArray *value_array = g_slice_new (GValueArray);

  value_array->n_values = 0;
  value_array->n_prealloced = 0;
  value_array->values = NULL;
  value_array_grow (value_array, n_prealloced, TRUE);
  value_array->n_values = 0;

  return value_array;
}
Ejemplo n.º 3
0
/**
 * g_value_array_new:
 * @n_prealloced: number of values to preallocate space for
 *
 * Allocate and initialize a new #GValueArray, optionally preserve space
 * for @n_prealloced elements. New arrays always contain 0 elements,
 * regardless of the value of @n_prealloced.
 *
 * Returns: a newly allocated #GValueArray with 0 values
 */
GValueArray*
g_value_array_new (guint n_prealloced)
{
  GValueArray *value_array = g_slice_new (GValueArray);
#ifdef GSTREAMER_LITE
  if (value_array == NULL) {
    return NULL;
  }
#endif // GSTREAMER_LITE

  value_array->n_values = 0;
  value_array->n_prealloced = 0;
  value_array->values = NULL;
  value_array_grow (value_array, n_prealloced, TRUE);
  value_array->n_values = 0;

  return value_array;
}
Ejemplo n.º 4
0
/**
 * g_value_array_insert:
 * @value_array: #GValueArray to add an element to
 * @index_: insertion position, must be <= value_array->;n_values
 * @value: (allow-none): #GValue to copy into #GValueArray, or %NULL
 *
 * Insert a copy of @value at specified position into @value_array. If @value
 * is %NULL, an uninitialized value is inserted.
 *
 * Returns: (transfer none): the #GValueArray passed in as @value_array
 *
 * Deprecated: 2.32: Use #GArray and g_array_insert_val() instead.
 */
GValueArray*
g_value_array_insert (GValueArray  *value_array,
		      guint         index,
		      const GValue *value)
{
  guint i;

  g_return_val_if_fail (value_array != NULL, NULL);
  g_return_val_if_fail (index <= value_array->n_values, value_array);

  i = value_array->n_values;
  value_array_grow (value_array, value_array->n_values + 1, FALSE);
  if (index + 1 < value_array->n_values)
    memmove (value_array->values + index + 1, value_array->values + index,
             (i - index) * sizeof (value_array->values[0]));
  memset (value_array->values + index, 0, sizeof (value_array->values[0]));
  if (value)
    {
      g_value_init (value_array->values + index, G_VALUE_TYPE (value));
      g_value_copy (value, value_array->values + index);
    }
  return value_array;
}