~ubuntu-branches/ubuntu/maverick/glib2.0/maverick

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Arrays</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-data-types.html" title="GLib Data Types">
<link rel="prev" href="glib-String-Chunks.html" title="String Chunks">
<link rel="next" href="glib-Pointer-Arrays.html" title="Pointer Arrays">
<meta name="generator" content="GTK-Doc V1.15.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-String-Chunks.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Pointer-Arrays.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Arrays.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Arrays.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-Arrays"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Arrays.top_of_page"></a>Arrays</span></h2>
<p>Arrays — arrays of arbitrary elements which grow
                    automatically as elements are added</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-Arrays.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;glib.h&gt;

                    <a class="link" href="glib-Arrays.html#GArray" title="GArray">GArray</a>;
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-new" title="g_array_new ()">g_array_new</a>                         (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> zero_terminated</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> clear_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> element_size</code></em>);
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-sized-new" title="g_array_sized_new ()">g_array_sized_new</a>                   (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> zero_terminated</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> clear_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> element_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> reserved_size</code></em>);
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-ref" title="g_array_ref ()">g_array_ref</a>                         (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Arrays.html#g-array-unref" title="g_array_unref ()">g_array_unref</a>                       (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);
<a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               <a class="link" href="glib-Arrays.html#g-array-get-element-size" title="g_array_get_element_size ()">g_array_get_element_size</a>            (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);
#define             <a class="link" href="glib-Arrays.html#g-array-append-val" title="g_array_append_val()">g_array_append_val</a>                  (a,
                                                         v)
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-append-vals" title="g_array_append_vals ()">g_array_append_vals</a>                 (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);
#define             <a class="link" href="glib-Arrays.html#g-array-prepend-val" title="g_array_prepend_val()">g_array_prepend_val</a>                 (a,
                                                         v)
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-prepend-vals" title="g_array_prepend_vals ()">g_array_prepend_vals</a>                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);
#define             <a class="link" href="glib-Arrays.html#g-array-insert-val" title="g_array_insert_val()">g_array_insert_val</a>                  (a,
                                                         i,
                                                         v)
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-insert-vals" title="g_array_insert_vals ()">g_array_insert_vals</a>                 (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-remove-index" title="g_array_remove_index ()">g_array_remove_index</a>                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-remove-index-fast" title="g_array_remove_index_fast ()">g_array_remove_index_fast</a>           (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-remove-range" title="g_array_remove_range ()">g_array_remove_range</a>                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Arrays.html#g-array-sort" title="g_array_sort ()">g_array_sort</a>                        (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Arrays.html#g-array-sort-with-data" title="g_array_sort_with_data ()">g_array_sort_with_data</a>              (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
#define             <a class="link" href="glib-Arrays.html#g-array-index" title="g_array_index()">g_array_index</a>                       (a,
                                                         t,
                                                         i)
<a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            <a class="link" href="glib-Arrays.html#g-array-set-size" title="g_array_set_size ()">g_array_set_size</a>                    (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);
<a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             <a class="link" href="glib-Arrays.html#g-array-free" title="g_array_free ()">g_array_free</a>                        (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> free_segment</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="glib-Arrays.description"></a><h2>Description</h2>
<p>
Arrays are similar to standard C arrays, except that they grow
automatically as elements are added.
</p>
<p>
Array elements can be of any size (though all elements of one array
are the same size), and the array can be automatically cleared to
'0's and zero-terminated.
</p>
<p>
To create a new array use <a class="link" href="glib-Arrays.html#g-array-new" title="g_array_new ()"><code class="function">g_array_new()</code></a>.
</p>
<p>
To add elements to an array, use <a class="link" href="glib-Arrays.html#g-array-append-val" title="g_array_append_val()"><code class="function">g_array_append_val()</code></a>,
<a class="link" href="glib-Arrays.html#g-array-append-vals" title="g_array_append_vals ()"><code class="function">g_array_append_vals()</code></a>, <a class="link" href="glib-Arrays.html#g-array-prepend-val" title="g_array_prepend_val()"><code class="function">g_array_prepend_val()</code></a>, and
<a class="link" href="glib-Arrays.html#g-array-prepend-vals" title="g_array_prepend_vals ()"><code class="function">g_array_prepend_vals()</code></a>.
</p>
<p>
To access an element of an array, use <a class="link" href="glib-Arrays.html#g-array-index" title="g_array_index()"><code class="function">g_array_index()</code></a>.
</p>
<p>
To set the size of an array, use <a class="link" href="glib-Arrays.html#g-array-set-size" title="g_array_set_size ()"><code class="function">g_array_set_size()</code></a>.
</p>
<p>
To free an array, use <a class="link" href="glib-Arrays.html#g-array-free" title="g_array_free ()"><code class="function">g_array_free()</code></a>.
</p>
<p>
</p>
<div class="example">
<a name="id868021"></a><p class="title"><b>Example 19. Using a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> to store <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> values</b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">GArray</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">garray</span><span class="symbol">;</span>
<span class="usertype">gint</span><span class="normal"> i</span><span class="symbol">;</span>
<span class="comment">/* We create a new array to store gint values.</span>
<span class="comment">   We don't want it zero-terminated or cleared to 0's. */</span>
<span class="normal">garray </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="glib-Arrays.html#g-array-new">g_array_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">,</span><span class="normal"> </span><span class="keyword">sizeof</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gint">gint</a></span><span class="symbol">));</span>
<span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> </span><span class="number">10000</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">  </span><span class="function"><a href="glib-Arrays.html#g-array-append-val">g_array_append_val</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">garray</span><span class="symbol">,</span><span class="normal"> i</span><span class="symbol">);</span>
<span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> </span><span class="number">10000</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">  </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Arrays.html#g-array-index">g_array_index</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">garray</span><span class="symbol">,</span><span class="normal"> <a href="glib-Basic-Types.html#gint">gint</a></span><span class="symbol">,</span><span class="normal"> i</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> i</span><span class="symbol">)</span>
<span class="normal">    </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"ERROR: got %d instead of %d</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">,</span>
<span class="normal">             </span><span class="function"><a href="glib-Arrays.html#g-array-index">g_array_index</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">garray</span><span class="symbol">,</span><span class="normal"> <a href="glib-Basic-Types.html#gint">gint</a></span><span class="symbol">,</span><span class="normal"> i</span><span class="symbol">),</span><span class="normal"> i</span><span class="symbol">);</span>
<span class="function"><a href="glib-Arrays.html#g-array-free">g_array_free</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">garray</span><span class="symbol">,</span><span class="normal"> <a href="glib-Standard-Macros.html#TRUE:CAPS">TRUE</a></span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break">
</p>
</div>
<div class="refsect1">
<a name="glib-Arrays.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GArray"></a><h3>GArray</h3>
<pre class="programlisting">typedef struct {
  gchar *data;
  guint len;
} GArray;
</pre>
<p>
Contains the public fields of an Array.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *<em class="structfield"><code><a name="GArray.data"></a>data</code></em>;</span></p></td>
<td>a pointer to the element data. The data may be moved as
       elements are added to the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GArray.len"></a>len</code></em>;</span></p></td>
<td>the number of elements in the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> not including the
      possible terminating zero element.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-new"></a><h3>g_array_new ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_new                         (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> zero_terminated</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> clear_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> element_size</code></em>);</pre>
<p>
Creates a new <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> with a reference count of 1.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>zero_terminated</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the array should have an extra element at
                  the end which is set to 0.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>clear_</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> elements should be automatically cleared
         to 0 when they are allocated.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>element_size</code></em> :</span></p></td>
<td>the size of each element in bytes.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the new <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-sized-new"></a><h3>g_array_sized_new ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_sized_new                   (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> zero_terminated</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> clear_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> element_size</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> reserved_size</code></em>);</pre>
<p>
Creates a new <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> with <em class="parameter"><code>reserved_size</code></em> elements preallocated and
a reference count of 1. This avoids frequent reallocation, if you
are going to add many elements to the array. Note however that the
size of the array is still 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>zero_terminated</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the array should have an extra element at
                  the end with all bits cleared.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>clear_</code></em> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if all bits in the array should be cleared to 0 on
         allocation.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>element_size</code></em> :</span></p></td>
<td>size of each element in the array.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>reserved_size</code></em> :</span></p></td>
<td>number of elements preallocated.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the new <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-ref"></a><h3>g_array_ref ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_ref                         (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);</pre>
<p>
Atomically increments the reference count of <em class="parameter"><code>array</code></em> by one. This
function is MT-safe and may be called from any thread.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> The passed in <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-array-unref"></a><h3>g_array_unref ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_array_unref                       (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);</pre>
<p>
Atomically decrements the reference count of <em class="parameter"><code>array</code></em> by one. If the
reference count drops to 0, all memory allocated by the array is
released. This function is MT-safe and may be called from any
thread.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-array-get-element-size"></a><h3>g_array_get_element_size ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="returnvalue">guint</span></a>               g_array_get_element_size            (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>);</pre>
<p>
Gets the size of the elements in <em class="parameter"><code>array</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>A <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> Size of each element, in bytes.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-array-append-val"></a><h3>g_array_append_val()</h3>
<pre class="programlisting">#define             g_array_append_val(a,v)</pre>
<p>
Adds the value on to the end of the array. The array will grow in
size automatically if necessary.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p><a class="link" href="glib-Arrays.html#g-array-append-val" title="g_array_append_val()"><code class="function">g_array_append_val()</code></a> is a macro which uses a reference
to the value parameter <em class="parameter"><code>v</code></em>. This means that you cannot use it with
literal values such as "27". You must use variables.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em> :</span></p></td>
<td>the value to append to the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-append-vals"></a><h3>g_array_append_vals ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_append_vals                 (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);</pre>
<p>
Adds <em class="parameter"><code>len</code></em> elements onto the end of the array.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>a pointer to the elements to append to the end of the array.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>the number of elements to append.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-prepend-val"></a><h3>g_array_prepend_val()</h3>
<pre class="programlisting">#define             g_array_prepend_val(a,v)</pre>
<p>
Adds the value on to the start of the array. The array will grow in
size automatically if necessary.
</p>
<p>
This operation is slower than <a class="link" href="glib-Arrays.html#g-array-append-val" title="g_array_append_val()"><code class="function">g_array_append_val()</code></a> since the
existing elements in the array have to be moved to make space for
the new element.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p><a class="link" href="glib-Arrays.html#g-array-prepend-val" title="g_array_prepend_val()"><code class="function">g_array_prepend_val()</code></a> is a macro which uses a reference
to the value parameter <em class="parameter"><code>v</code></em>. This means that you cannot use it with
literal values such as "27". You must use variables.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em> :</span></p></td>
<td>the value to prepend to the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-prepend-vals"></a><h3>g_array_prepend_vals ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_prepend_vals                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);</pre>
<p>
Adds <em class="parameter"><code>len</code></em> elements onto the start of the array.
</p>
<p>
This operation is slower than <a class="link" href="glib-Arrays.html#g-array-append-vals" title="g_array_append_vals ()"><code class="function">g_array_append_vals()</code></a> since the
existing elements in the array have to be moved to make space for
the new elements.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>a pointer to the elements to prepend to the start of the
       array.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>the number of elements to prepend.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-insert-val"></a><h3>g_array_insert_val()</h3>
<pre class="programlisting">#define             g_array_insert_val(a,i,v)</pre>
<p>
Inserts an element into an array at the given index.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p><a class="link" href="glib-Arrays.html#g-array-insert-val" title="g_array_insert_val()"><code class="function">g_array_insert_val()</code></a> is a macro which uses a reference
to the value parameter <em class="parameter"><code>v</code></em>. This means that you cannot use it with
literal values such as "27". You must use variables.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>i</code></em> :</span></p></td>
<td>the index to place the element at.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>v</code></em> :</span></p></td>
<td>the value to insert into the array.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-insert-vals"></a><h3>g_array_insert_vals ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_insert_vals                 (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer"><span class="type">gconstpointer</span></a> data</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> len</code></em>);</pre>
<p>
Inserts <em class="parameter"><code>len</code></em> elements into a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> at the given index.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index to place the elements at.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>a pointer to the elements to insert.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>the number of elements to insert.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-remove-index"></a><h3>g_array_remove_index ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_remove_index                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);</pre>
<p>
Removes the element at the given index from a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>. The following
elements are moved down one place.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the element to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-remove-index-fast"></a><h3>g_array_remove_index_fast ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_remove_index_fast           (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>);</pre>
<p>
Removes the element at the given index from a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>. The last
element in the array is used to fill in the space, so this function
does not preserve the order of the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>. But it is faster than
<a class="link" href="glib-Arrays.html#g-array-remove-index" title="g_array_remove_index ()"><code class="function">g_array_remove_index()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <em class="parameter"><code>GArray</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the element to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-remove-range"></a><h3>g_array_remove_range ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_remove_range                (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> index_</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);</pre>
<p>
Removes the given number of elements starting at the given index
from a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.  The following elements are moved to close the gap.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <em class="parameter"><code>GArray</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>index_</code></em> :</span></p></td>
<td>the index of the first element to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>the number of elements to remove.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-array-sort"></a><h3>g_array_sort ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_array_sort                        (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareFunc" title="GCompareFunc ()"><span class="type">GCompareFunc</span></a> compare_func</code></em>);</pre>
<p>
Sorts a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> using <em class="parameter"><code>compare_func</code></em> which should be a <code class="function">qsort()</code>-style
comparison function (returns less than zero for first arg is less
than second arg, zero for equal, greater zero if first arg is
greater than second arg).
</p>
<p>
If two array elements compare equal, their order in the sorted array
is undefined.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
<td>comparison function.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-sort-with-data"></a><h3>g_array_sort_with_data ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_array_sort_with_data              (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> compare_func</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Like <a class="link" href="glib-Arrays.html#g-array-sort" title="g_array_sort ()"><code class="function">g_array_sort()</code></a>, but the comparison function receives an extra
user data argument.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>compare_func</code></em> :</span></p></td>
<td>comparison function.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>compare_func</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-index"></a><h3>g_array_index()</h3>
<pre class="programlisting">#define             g_array_index(a,t,i)</pre>
<p>
Returns the element of a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> at the given index. The return
value is cast to the given type.
</p>
<p>
</p>
<div class="example">
<a name="id953427"></a><p class="title"><b>Example 20. Getting a pointer to an element in a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a></b></p>
<div class="example-contents">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">EDayViewEvent</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">event</span><span class="symbol">;</span>
<span class="comment">/* This gets a pointer to the 4th element</span>
<span class="comment">   in the array of EDayViewEvent structs. */</span>
<span class="normal">event </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">&amp;</span><span class="function"><a href="glib-Arrays.html#g-array-index">g_array_index</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">events</span><span class="symbol">,</span><span class="normal"> EDayViewEvent</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

</div>
<p><br class="example-break">
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>t</code></em> :</span></p></td>
<td>the type of the elements.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>i</code></em> :</span></p></td>
<td>the index of the element to return.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the element of the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> at the index given by <em class="parameter"><code>i</code></em>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-set-size"></a><h3>g_array_set_size ()</h3>
<pre class="programlisting"><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="returnvalue">GArray</span></a> *            g_array_set_size                    (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint" title="guint"><span class="type">guint</span></a> length</code></em>);</pre>
<p>
Sets the size of the array, expanding it if necessary. If the array
was created with <em class="parameter"><code>clear_</code></em> set to <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, the new elements are set to 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>length</code></em> :</span></p></td>
<td>the new size of the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
<hr>
<div class="refsect2">
<a name="g-array-free"></a><h3>g_array_free ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *             g_array_free                        (<em class="parameter"><code><a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> *array</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="type">gboolean</span></a> free_segment</code></em>);</pre>
<p>
Frees the memory allocated for the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>. If <em class="parameter"><code>free_segment</code></em> is
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> it frees the memory block holding the elements as well and
also each element if <em class="parameter"><code>array</code></em> has a <em class="parameter"><code>element_free_func</code></em> set. Pass
<a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> if you want to free the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> wrapper but preserve the
underlying array for use elsewhere. If the reference count of <em class="parameter"><code>array</code></em>
is greater than one, the <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a> wrapper is preserved but the size
of <em class="parameter"><code>array</code></em> will be set to zero.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>If array elements contain dynamically-allocated memory,
they should be freed separately.</p>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
<td>a <a class="link" href="glib-Arrays.html#GArray" title="GArray"><span class="type">GArray</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>free_segment</code></em> :</span></p></td>
<td>if <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> the actual element data is freed as well.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the element data if <em class="parameter"><code>free_segment</code></em> is <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a>, otherwise
          <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.  The element data should be freed using <a class="link" href="glib-Memory-Allocation.html#g-free" title="g_free ()"><code class="function">g_free()</code></a>.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.15.1</div>
</body>
</html>