[gtk+] x11: Use glib malloc funcs for XSettings
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Use glib malloc funcs for XSettings
- Date: Tue, 19 Feb 2013 13:47:42 +0000 (UTC)
commit 08a6f554c3d9ee157cddaefa2d7fd26458f2737b
Author: Benjamin Otte <otte redhat com>
Date: Tue Feb 12 14:58:44 2013 +0100
x11: Use glib malloc funcs for XSettings
gdk/x11/xsettings-client.c | 35 ++++++++---------------------------
gdk/x11/xsettings-client.h | 1 -
2 files changed, 8 insertions(+), 28 deletions(-)
---
diff --git a/gdk/x11/xsettings-client.c b/gdk/x11/xsettings-client.c
index da7d55b..3920bec 100644
--- a/gdk/x11/xsettings-client.c
+++ b/gdk/x11/xsettings-client.c
@@ -31,7 +31,6 @@
#include <limits.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
@@ -225,20 +224,10 @@ parse_settings (unsigned char *data,
goto out;
}
- setting = malloc (sizeof *setting);
- if (!setting)
- {
- result = XSETTINGS_NO_MEM;
- goto out;
- }
+ setting = g_new (XSettingsSetting, 1);
setting->type = XSETTINGS_TYPE_INT; /* No allocated memory */
- setting->name = malloc (name_len + 1);
- if (!setting->name)
- {
- result = XSETTINGS_NO_MEM;
- goto out;
- }
+ setting->name = g_malloc (name_len + 1);
memcpy (setting->name, buffer.pos, name_len);
setting->name[name_len] = '\0';
@@ -271,12 +260,7 @@ parse_settings (unsigned char *data,
goto out;
}
- setting->data.v_string = malloc (v_int + 1);
- if (!setting->data.v_string)
- {
- result = XSETTINGS_NO_MEM;
- goto out;
- }
+ setting->data.v_string = g_malloc (v_int + 1);
memcpy (setting->data.v_string, buffer.pos, v_int);
setting->data.v_string[v_int] = '\0';
@@ -326,9 +310,6 @@ parse_settings (unsigned char *data,
{
switch (result)
{
- case XSETTINGS_NO_MEM:
- fprintf(stderr, "Out of memory reading XSETTINGS property\n");
- break;
case XSETTINGS_ACCESS:
fprintf(stderr, "Invalid XSETTINGS property (read off end)\n");
break;
@@ -456,7 +437,7 @@ xsettings_client_new (GdkScreen *screen,
char *atom_names[3];
Atom atoms[3];
- client = malloc (sizeof *client);
+ client = g_new (XSettingsClient, 1);
if (!client)
return NULL;
@@ -503,7 +484,7 @@ xsettings_client_destroy (XSettingsClient *client)
if (client->settings)
g_hash_table_unref (client->settings);
- free (client);
+ g_free (client);
}
const XSettingsSetting *
@@ -580,11 +561,11 @@ void
xsettings_setting_free (XSettingsSetting *setting)
{
if (setting->type == XSETTINGS_TYPE_STRING)
- free (setting->data.v_string);
+ g_free (setting->data.v_string);
if (setting->name)
- free (setting->name);
+ g_free (setting->name);
- free (setting);
+ g_free (setting);
}
diff --git a/gdk/x11/xsettings-client.h b/gdk/x11/xsettings-client.h
index 69ffca1..6bb2dbc 100644
--- a/gdk/x11/xsettings-client.h
+++ b/gdk/x11/xsettings-client.h
@@ -64,7 +64,6 @@ typedef enum
typedef enum
{
XSETTINGS_SUCCESS,
- XSETTINGS_NO_MEM,
XSETTINGS_ACCESS,
XSETTINGS_FAILED,
XSETTINGS_NO_ENTRY,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]