Home

garraynew

garraynew is a constructor used to allocate and initialize a dynamic array in the GLib library’s GArray data structure. It creates a new GArray that stores elements of a user-specified size and is commonly used when a program needs a growable, typed array. In GLib sources, the function is named g_array_new; some bindings or informal references call it garraynew.

Signature: GArray* g_array_new(gboolean zero_terminated, gboolean clear, guint element_size). The parameters are described as follows: zero_terminated indicates

Behavior: The function allocates the array structure and the internal storage for the given element size. If

Return value and memory management: On success, g_array_new returns a pointer to a new GArray; on failure,

See also: GArray, g_array_free, g_array_append_val, and related GArray utilities. These functions form the typical workflow for

whether
a
trailing
terminator
element
should
be
maintained
in
the
array;
clear,
when
TRUE,
initializes
new
memory
to
zero;
element_size
specifies
the
size,
in
bytes,
of
each
array
element.
zero_terminated
is
TRUE,
the
array
reserves
space
for
and
maintains
a
terminator
element
(such
as
NULL
for
pointer
arrays
or
0
for
numeric
elements).
If
clear
is
TRUE,
newly
allocated
elements
are
zeroed.
This
function
creates
a
brand-new
array
and
does
not
modify
existing
data.
it
returns
NULL.
The
caller
is
responsible
for
freeing
resources
when
the
array
is
no
longer
needed,
typically
with
g_array_free,
passing
a
boolean
to
indicate
whether
to
free
the
underlying
data
as
well.
managing
dynamic,
type-specific
arrays
in
GLib-based
code.