- st->pd = malloc(st->npix * (st->pdepth == 1 ? 1 : (st->pdepth / 8)));
- if (!st->pd) {
- fprintf(stderr, "not enough memory for %d pixels.\n", st->npix);
- exit(1);
- }
-
- st->image = 0;
-
-#ifdef HAVE_XSHM_EXTENSION
- if (st->use_shm)
- {
- st->image = create_xshm_image(st->dpy, st->xgwa.visual, vdepth,
- ZPixmap, 0, &st->shm_info, st->width, st->height);
- if (!st->image)
- st->use_shm = False;
- else
- {
- free(st->pd);
- st->pd = st->image->data;
- }
- }
-#endif /* HAVE_XSHM_EXTENSION */
-
- if (!st->image)
- {
- st->image = XCreateImage(st->dpy, st->xgwa.visual, vdepth,
- ZPixmap, 0, st->pd,
- st->width, st->height, 8, 0);
- }
+ st->image = create_xshm_image(st->dpy, st->xgwa.visual, vdepth,
+ ZPixmap, &st->shm_info, st->width, st->height);
+ st->pd = st->image->data;