~ubuntu-branches/ubuntu/precise/glib2.0/precise-updates

« back to all changes in this revision

Viewing changes to glib/garray.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-02-02 19:24:45 UTC
  • mfrom: (1.59.38)
  • Revision ID: package-import@ubuntu.com-20120202192445-n258a4h70odnnq4m
Tags: 2.31.14-0ubuntu1
* New upstream version:
  GResource:
  - GLib now includes a commandline utility, gresource, to explore 
    resources in ELF files
  - The resource compiler can now optionally strip ignorable 
    whitespace from XML resources
  - The resource compiler can now generate build dependencies
  - The resource compiler will now autoselect output formats
  GApplication:
  - The menu markup parser API has been dropped, the menu XML support 
    lives in GTK+ now
  GValueArray has been deprecated
* debian/libglib2.0-0.symbols: 
  - new version update
* debian/libglib2.0-bin.install:
  - list the new gresource command and its manpage
* debian/control.in:
  - Breaks on gtk << 3.3.12, glib and gtk needs to be updated together
    due to the gmenu parser changes
  - Build-Depends on libelf-dev for the gresources tools, thanks ricotz
* debian/docs:
  - dropped, no need to install ChangeLog and NEWS from the past century
* debian/libglib2.0-bin.install:
  - ship the glib-compile-resources manpage, thanks ricotz
* debian/patches/git_gsettings_lists_set.patch:
  - git patch, fix "gsettings set ..." command line issues (lp: #925382)

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
  guint   zero_terminated : 1;
111
111
  guint   clear : 1;
112
112
  gint    ref_count;
 
113
  GDestroyNotify clear_func;
113
114
};
114
115
 
115
116
/**
200
201
  array->clear           = (clear ? 1 : 0);
201
202
  array->elt_size        = elt_size;
202
203
  array->ref_count       = 1;
 
204
  array->clear_func      = NULL;
203
205
 
204
206
  if (array->zero_terminated || reserved_size != 0)
205
207
    {
211
213
}
212
214
 
213
215
/**
 
216
 * g_array_set_clear_func:
 
217
 * @array: A #GArray
 
218
 * @clear_func: a function to clear an element of @array
 
219
 *
 
220
 * Sets a function to clear an element of @array.
 
221
 *
 
222
 * The @clear_func will be called when an element in the array
 
223
 * data segment is removed and when the array is freed and data
 
224
 * segment is deallocated as well.
 
225
 *
 
226
 * Note that in contrast with other uses of #GDestroyNotify
 
227
 * functions, @clear_func is expected to clear the contents of
 
228
 * the array element it is given, but not free the element itself.
 
229
 *
 
230
 * Since: 2.32
 
231
 */
 
232
void
 
233
g_array_set_clear_func (GArray         *array,
 
234
                        GDestroyNotify  clear_func)
 
235
{
 
236
  GRealArray *rarray = (GRealArray *) array;
 
237
 
 
238
  g_return_if_fail (array != NULL);
 
239
 
 
240
  rarray->clear_func = clear_func;
 
241
}
 
242
 
 
243
/**
214
244
 * g_array_ref:
215
245
 * @array: A #GArray.
216
246
 *
325
355
 
326
356
  if (flags & FREE_SEGMENT)
327
357
    {
 
358
      if (array->clear_func != NULL)
 
359
        {
 
360
          guint i;
 
361
 
 
362
          for (i = 0; i < array->len; i++)
 
363
            array->clear_func (g_array_elt_pos (array, i));
 
364
        }
 
365
 
328
366
      g_free (array->data);
329
367
      segment = NULL;
330
368
    }
514
552
      if (array->clear)
515
553
        g_array_elt_zero (array, array->len, length - array->len);
516
554
    }
517
 
  else if (G_UNLIKELY (g_mem_gc_friendly) && length < array->len)
518
 
    g_array_elt_zero (array, length, array->len - length);
 
555
  else if (length < array->len)
 
556
    g_array_remove_range (farray, length, array->len - length);
519
557
  
520
558
  array->len = length;
521
559
  
543
581
 
544
582
  g_return_val_if_fail (index_ < array->len, NULL);
545
583
 
 
584
  if (array->clear_func != NULL)
 
585
    array->clear_func (g_array_elt_pos (array, index_));
 
586
 
546
587
  if (index_ != array->len - 1)
547
588
    g_memmove (g_array_elt_pos (array, index_),
548
 
               g_array_elt_pos (array, index_ + 1),
549
 
               g_array_elt_len (array, array->len - index_ - 1));
550
 
  
 
589
               g_array_elt_pos (array, index_ + 1),
 
590
               g_array_elt_len (array, array->len - index_ - 1));
 
591
 
551
592
  array->len -= 1;
552
593
 
553
594
  if (G_UNLIKELY (g_mem_gc_friendly))
579
620
 
580
621
  g_return_val_if_fail (index_ < array->len, NULL);
581
622
 
 
623
  if (array->clear_func != NULL)
 
624
    array->clear_func (g_array_elt_pos (array, index_));
 
625
 
582
626
  if (index_ != array->len - 1)
583
 
    memcpy (g_array_elt_pos (array, index_), 
584
 
            g_array_elt_pos (array, array->len - 1),
585
 
            g_array_elt_len (array, 1));
 
627
    memcpy (g_array_elt_pos (array, index_),
 
628
            g_array_elt_pos (array, array->len - 1),
 
629
            g_array_elt_len (array, 1));
586
630
  
587
631
  array->len -= 1;
588
632
 
617
661
  g_return_val_if_fail (index_ < array->len, NULL);
618
662
  g_return_val_if_fail (index_ + length <= array->len, NULL);
619
663
 
 
664
  if (array->clear_func != NULL)
 
665
    {
 
666
      guint i;
 
667
 
 
668
      for (i = 0; i < length; i++)
 
669
        array->clear_func (g_array_elt_pos (array, index_ + i));
 
670
    }
 
671
 
620
672
  if (index_ + length != array->len)
621
 
    g_memmove (g_array_elt_pos (array, index_), 
622
 
               g_array_elt_pos (array, index_ + length), 
 
673
    g_memmove (g_array_elt_pos (array, index_),
 
674
               g_array_elt_pos (array, index_ + length),
623
675
               (array->len - (index_ + length)) * array->elt_size);
624
676
 
625
677
  array->len -= length;