Lines 40-46
Link Here
|
40 |
#include "gthread.h" |
40 |
#include "gthread.h" |
41 |
#include "gtestutils.h" |
41 |
#include "gtestutils.h" |
42 |
#include "glib_trace.h" |
42 |
#include "glib_trace.h" |
43 |
#include "glib-init.h" |
|
|
44 |
|
43 |
|
45 |
#define QUARK_BLOCK_SIZE 2048 |
44 |
#define QUARK_BLOCK_SIZE 2048 |
46 |
#define QUARK_STRING_BLOCK_SIZE (4096 - sizeof (gsize)) |
45 |
#define QUARK_STRING_BLOCK_SIZE (4096 - sizeof (gsize)) |
Lines 54-69
static gint quark_seq_id = 0;
Link Here
|
54 |
static gchar *quark_block = NULL; |
53 |
static gchar *quark_block = NULL; |
55 |
static gint quark_block_offset = 0; |
54 |
static gint quark_block_offset = 0; |
56 |
|
55 |
|
57 |
void |
|
|
58 |
g_quark_init (void) |
59 |
{ |
60 |
g_assert (quark_seq_id == 0); |
61 |
quark_ht = g_hash_table_new (g_str_hash, g_str_equal); |
62 |
quarks = g_new (gchar*, QUARK_BLOCK_SIZE); |
63 |
quarks[0] = NULL; |
64 |
quark_seq_id = 1; |
65 |
} |
66 |
|
67 |
/** |
56 |
/** |
68 |
* SECTION:quarks |
57 |
* SECTION:quarks |
69 |
* @title: Quarks |
58 |
* @title: Quarks |
Lines 138-146
g_quark_try_string (const gchar *string)
Link Here
|
138 |
return 0; |
127 |
return 0; |
139 |
|
128 |
|
140 |
G_LOCK (quark_global); |
129 |
G_LOCK (quark_global); |
141 |
quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); |
130 |
if (quark_ht) |
|
|
131 |
quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); |
142 |
G_UNLOCK (quark_global); |
132 |
G_UNLOCK (quark_global); |
143 |
|
133 |
|
144 |
return quark; |
134 |
return quark; |
145 |
} |
135 |
} |
146 |
|
136 |
|
Lines 179-185
quark_from_string (const gchar *string,
Link Here
|
179 |
{ |
169 |
{ |
180 |
GQuark quark = 0; |
170 |
GQuark quark = 0; |
181 |
|
171 |
|
182 |
quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); |
172 |
if (quark_ht) |
|
|
173 |
quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); |
183 |
|
174 |
|
184 |
if (!quark) |
175 |
if (!quark) |
185 |
{ |
176 |
{ |
Lines 292-297
quark_new (gchar *string)
Link Here
|
292 |
*/ |
283 |
*/ |
293 |
g_atomic_pointer_set (&quarks, quarks_new); |
284 |
g_atomic_pointer_set (&quarks, quarks_new); |
294 |
} |
285 |
} |
|
|
286 |
if (!quark_ht) |
287 |
{ |
288 |
g_assert (quark_seq_id == 0); |
289 |
quark_ht = g_hash_table_new (g_str_hash, g_str_equal); |
290 |
quarks[quark_seq_id] = NULL; |
291 |
g_atomic_int_inc (&quark_seq_id); |
292 |
} |
295 |
|
293 |
|
296 |
quark = quark_seq_id; |
294 |
quark = quark_seq_id; |
297 |
g_atomic_pointer_set (&quarks[quark], string); |
295 |
g_atomic_pointer_set (&quarks[quark], string); |
298 |
- |
|
|