Home

GQuark

GQuark is a string interning facility used by GLib, the low-level core library of the GNOME platform. It provides a way to map strings to small, unique integers that can be compared quickly. In GLib, a GQuark is a typedef for guint32, representing a unique identifier for a string within the lifetime of a process.

Quarks are created on demand through functions such as g_quark_from_string, which registers a string in an internal

For performance and convenience, GLib also provides g_quark_from_static_string for strings with static storage duration. This variant

Key characteristics and usage notes include that quarks are process-local and do not cross process boundaries;

table
and
returns
its
quark.
If
the
same
string
is
requested
again,
the
same
quark
is
returned,
enabling
fast,
integer-based
comparisons
instead
of
repeated
string
comparisons.
The
function
g_quark_to_string
can
be
used
to
retrieve
the
original
string
from
a
quark,
facilitating
round
trips
between
string
form
and
quark
form.
registers
the
string
without
duplicating
it
and
is
intended
for
constant
strings
known
at
compile
time.
their
primary
benefit
is
speed
and
memory
efficiency
within
a
single
running
program.
Quarks
persist
for
the
duration
of
the
process,
and
the
intern
table
is
typically
freed
when
the
program
exits.
GQuark
is
widely
used
within
GLib
and
GObject-based
code
to
represent
frequently
compared
strings,
such
as
property
names,
error
domains,
and
other
identifiers,
enabling
faster
comparisons
and
reduced
string
storage
overhead.