- PlanarSurface *p;
- if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap);
- if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
- if (a->textures)
- g_free(a->texture);
- if (a->surface.type == Surface_Planar) {
- p = &a->surface.data.planar;
- if (p->primary != NULL) color_free(p->primary);
- if (p->secondary != NULL) color_free(p->secondary);
- if (p->border_color != NULL) color_free(p->border_color);
- if (p->pixel_data != NULL) g_free(p->pixel_data);
+ if (a) {
+ PlanarSurface *p;
+ if (a->pixmap != None) XFreePixmap(ob_display, a->pixmap);
+ if (a->xftdraw != NULL) XftDrawDestroy(a->xftdraw);
+ if (a->textures)
+ g_free(a->texture);
+ if (a->surface.type == Surface_Planar) {
+ p = &a->surface.data.planar;
+ if (p->primary != NULL) color_free(p->primary);
+ if (p->secondary != NULL) color_free(p->secondary);
+ if (p->border_color != NULL) color_free(p->border_color);
+ if (p->pixel_data != NULL) g_free(p->pixel_data);
+ }
+ g_free(a);
}
void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
{
}
void pixel32_to_pixmap(pixel32 *in, Pixmap out, int x, int y, int w, int h)
{
XImage *im = NULL;
im = XCreateImage(ob_display, render_visual, render_depth,
ZPixmap, 0, NULL, w, h, 32, 0);
g_assert(im != NULL);
im->byte_order = endian;
XImage *im = NULL;
im = XCreateImage(ob_display, render_visual, render_depth,
ZPixmap, 0, NULL, w, h, 32, 0);
g_assert(im != NULL);
im->byte_order = endian;
- im->data = (char *)in;
- reduce_depth((pixel32*)im->data, im);
+/* this malloc is a complete waste of time on normal 32bpp
+ as reduce_depth just sets im->data = data and returns
+*/
+ scratch = malloc(im->width * im->height * sizeof(pixel32));
+ im->data = (char*) scratch;
+ reduce_depth(in, im);
XPutImage(ob_display, out, DefaultGC(ob_display, ob_screen),
im, 0, 0, x, y, w, h);
im->data = NULL;
XDestroyImage(im);
XPutImage(ob_display, out, DefaultGC(ob_display, ob_screen),
im, 0, 0, x, y, w, h);
im->data = NULL;
XDestroyImage(im);