Re: quarks
- From: "Martin (OpenGeoMap)" <martin opengeomap org>
- To: gtk-app-devel-list gnome org
- Cc: G Hasse <gorhas raditex se>
- Subject: Re: quarks
- Date: Mon, 01 Sep 2008 18:20:11 -0300
G Hasse wrote:
On Mon, Sep 01, 2008 at 09:16:14AM +0200, Martin (OpenGeoMap) wrote:
hi:
On Mon, Sep 01, 2008 at 02:20:35AM -0300, Martin (OpenGeoMap) wrote:
hi!,
Someone knows like quarks works in glib????.
I suppose quarks is a pun on "atoms" that is so
often used as a lingo for som small item. Like atoms
in X.
I can not find the source code, only the header. It?? suppose we
don need free the string inside a static string of a quarks. But
how is that???. Where is the string saved?.
A quark is a pointer to your objeckt. So it is stored inside your
program. If you don't need the quark any more you should free it.
GH
Since GQuark is just an integer that gives a string
in a GData list you should not manipulate the list yourself.
(Probalby..)
in FreeBSD look at
/usr/ports/devel/glib20/work/glib-2.14.2/glib/gdataset.c
...
GQuark
g_quark_from_string (const gchar *string)
{
GQuark quark;
if (!string)
return 0;
G_LOCK (g_quark_global);
quark = g_quark_from_string_internal (string, TRUE);
G_UNLOCK (g_quark_global);
return quark;
}
/* HOLDS: g_quark_global_lock */
static inline GQuark
g_quark_from_string_internal (const gchar *string,
gboolean duplicate)
{
GQuark quark = 0;
if (g_quark_ht)
quark = GPOINTER_TO_UINT (g_hash_table_lookup (g_quark_ht, string));
if (!quark)
quark = g_quark_new (duplicate ? g_strdup (string) : (gchar
*)string);
return quark;
}
/* HOLDS: g_quark_global_lock */
static inline GQuark
g_quark_new (gchar *string)
{
GQuark quark;
if (g_quark_seq_id % G_QUARK_BLOCK_SIZE == 0)
g_quarks = g_renew (gchar*, g_quarks, g_quark_seq_id +
G_QUARK_BLOCK_SIZE);
if (!g_quark_ht)
{
g_assert (g_quark_seq_id == 0);
g_quark_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_quarks[g_quark_seq_id++] = NULL;
}
quark = g_quark_seq_id++;
g_quarks[quark] = string;
g_hash_table_insert (g_quark_ht, string, GUINT_TO_POINTER (quark));
return quark;
}
So there is no god interface to removing entrys from the table.
There is a function to clear the entire list - but then you lose
all quarks...
g_datalist_clear_i (GData **datalist);
Thanks for all responses.
Regards.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]