Report memory allocation errors

This commit is contained in:
Pierre Pronchery 2015-05-24 16:07:47 +02:00
parent 20e2b78e72
commit 11fad60a17

View File

@ -29,6 +29,7 @@ static char const _license[] =
#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 0, 0)
# include <gtk/gtkx.h> # include <gtk/gtkx.h>
#endif #endif
#include <System.h>
#include <Desktop.h> #include <Desktop.h>
#define XK_LATIN1 #define XK_LATIN1
#define XK_MISCELLANY #define XK_MISCELLANY
@ -350,7 +351,7 @@ Keyboard * keyboard_new(KeyboardPrefs * prefs)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif #endif
if((keyboard = malloc(sizeof(*keyboard))) == NULL) if((keyboard = object_new(sizeof(*keyboard))) == NULL)
return NULL; return NULL;
keyboard->mode = prefs->mode; keyboard->mode = prefs->mode;
keyboard->layouts = NULL; keyboard->layouts = NULL;
@ -549,7 +550,7 @@ void keyboard_delete(Keyboard * keyboard)
#endif #endif
gtk_widget_destroy(keyboard->window); gtk_widget_destroy(keyboard->window);
pango_font_description_free(keyboard->font); pango_font_description_free(keyboard->font);
free(keyboard); object_delete(keyboard);
} }