xim = XCreateImage(dpy, visual, depth, ZPixmap, 0, NULL, w, h, BitmapPad(dpy), 0);
xim = XCreateImage_wr(dpy, default_visual, depth, ZPixmap, 0, NULL, w, h, BitmapPad(dpy), 0);
static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,    char *name) {	XImage *xim;	shm->shmid = -1;	shm->shmaddr = (char *) -1;	*ximg_ptr = NULL;	if (nofb) {		return 1;	}	X_LOCK;	if (! using_shm) {		/* we only need the XImage created */		xim = XCreateImage(dpy, visual, depth, ZPixmap, 0, NULL, w, h,		    BitmapPad(dpy), 0);		X_UNLOCK;		if (xim == NULL) {			rfbErr("XCreateImage(%s) failed.\n", name);			return 0;		}		xim->data = (char *) malloc(xim->bytes_per_line * xim->height);		if (xim->data == NULL) {			rfbErr("XCreateImage(%s) data malloc failed.\n", name);			return 0;		}		if (flip_byte_order) {			static int reported = 0;			char *bo;			if (xim->byte_order == LSBFirst) {				bo = "MSBFirst";				xim->byte_order = MSBFirst;				xim->bitmap_bit_order = MSBFirst;			} else {				bo = "LSBFirst";				xim->byte_order = LSBFirst;				xim->bitmap_bit_order = LSBFirst;			}			if (! reported && ! quiet) {				rfbLog("changing XImage byte order"				    " to %s\n", bo);				reported = 1;			}		}		*ximg_ptr = xim;		return 1;	}	xim = XShmCreateImage(dpy, visual, depth, ZPixmap, NULL, shm, w, h);	if (xim == NULL) {		rfbErr("XShmCreateImage(%s) failed.\n", name);		X_UNLOCK;		return 0;	}	*ximg_ptr = xim;	shm->shmid = shmget(IPC_PRIVATE,	    xim->bytes_per_line * xim->height, IPC_CREAT | 0777);	if (shm->shmid == -1) {		rfbErr("shmget(%s) failed.\n", name);		rfbLogPerror("shmget");		XDestroyImage(xim);		*ximg_ptr = NULL;		X_UNLOCK;		return 0;	}	shm->shmaddr = xim->data = (char *) shmat(shm->shmid, 0, 0);	if (shm->shmaddr == (char *)-1) {		rfbErr("shmat(%s) failed.\n", name);		rfbLogPerror("shmat");		XDestroyImage(xim);		*ximg_ptr = NULL;		shmctl(shm->shmid, IPC_RMID, 0);		shm->shmid = -1;		X_UNLOCK;		return 0;	}	shm->readOnly = False;	if (! XShmAttach(dpy, shm)) {		rfbErr("XShmAttach(%s) failed.\n", name);		XDestroyImage(xim);		*ximg_ptr = NULL;		shmdt(shm->shmaddr);		shm->shmaddr = (char *) -1;		shmctl(shm->shmid, IPC_RMID, 0);		shm->shmid = -1;		X_UNLOCK;		return 0;	}	X_UNLOCK;	return 1;}