diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-01-14 11:33:26 -0500 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-01-14 11:33:26 -0500 |
commit | 08529e13f62a33e7ed94a2319c9f35feea95fa6a (patch) | |
tree | ebe37f20c8a498dd991d68a1f9407ec55d476578 /gsettings | |
parent | 0e48388eb0d97d72c9914fe724e3a23b28d5e82c (diff) | |
download | dconf-08529e13f62a33e7ed94a2319c9f35feea95fa6a.tar.gz |
Use normal slice allocation for OutstandingWatch
The fact that the last commit broke the old code is proof that it was
far too fragile. Change it to use more common idioms (at the cost of an
extremely marginal increase in memory consumption).
Diffstat (limited to 'gsettings')
-rw-r--r-- | gsettings/dconfsettingsbackend.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gsettings/dconfsettingsbackend.c b/gsettings/dconfsettingsbackend.c index 0cab0d3..bbd3c32 100644 --- a/gsettings/dconfsettingsbackend.c +++ b/gsettings/dconfsettingsbackend.c @@ -478,7 +478,7 @@ typedef struct { DConfSettingsBackend *dcsb; guint64 state; - gchar name[1]; + gchar *name; gint outstanding; } OutstandingWatch; @@ -490,11 +490,11 @@ outstanding_watch_new (DConfSettingsBackend *dcsb, gsize length; length = strlen (name); - watch = g_malloc (G_STRUCT_OFFSET (OutstandingWatch, name) + length + 1); + watch = g_slice_new (OutstandingWatch); watch->dcsb = g_object_ref (dcsb); watch->state = dconf_engine_get_state (dcsb->engine); watch->outstanding = 0; - strcpy (watch->name, name); + watch->name = g_strdup (name); return watch; } @@ -505,7 +505,9 @@ outstanding_watch_free (OutstandingWatch *watch) if (--watch->outstanding == 0) { g_object_unref (watch->dcsb); - g_free (watch); + g_free (watch->name); + + g_slice_free (OutstandingWatch, watch); } } |