allow freeing NULL appearances

This commit is contained in:
Dana Jansens 2003-04-13 02:30:01 +00:00
parent ef1f7b0494
commit 76ebae32b2

View file

@ -359,6 +359,7 @@ Appearance *appearance_copy(Appearance *orig)
void appearance_free(Appearance *a) void appearance_free(Appearance *a)
{ {
if (a) {
PlanarSurface *p; PlanarSurface *p;
if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap); if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap);
if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw); if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
@ -372,6 +373,7 @@ void appearance_free(Appearance *a)
if (p->pixel_data != NULL) g_free(p->pixel_data); if (p->pixel_data != NULL) g_free(p->pixel_data);
} }
g_free(a); g_free(a);
}
} }
@ -387,7 +389,7 @@ void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
as reduce_depth just sets im->data = data and returns as reduce_depth just sets im->data = data and returns
*/ */
scratch = malloc(im->width * im->height * sizeof(pixel32)); scratch = malloc(im->width * im->height * sizeof(pixel32));
im->data = scratch; im->data = (char*) scratch;
reduce_depth(in, im); reduce_depth(in, im);
XPutImage(ob_display, out, DefaultGC(ob_display, ob_screen), XPutImage(ob_display, out, DefaultGC(ob_display, ob_screen),
im, 0, 0, x, y, w, h); im, 0, 0, x, y, w, h);
@ -433,5 +435,4 @@ void appearance_minsize(Appearance *l, Size *s)
} }
break; break;
} }
return s;
} }