rem: perror("wrlib:shmctl:");
add: perror("wrlib:shmctl");
context: RCreateXImage(RContext *context, int depth, unsigned width, unsigned height){    RXImage *rximg;        rximg = malloc(sizeof(RXImage));    if (!rximg) {	sprintf(RErrorString, "out of memory trying to create XImage");	return NULL;    }    #ifndef XSHM    rximg->image = XCreateImage(context->dpy, context->visual, depth,				ZPixmap, 0, NULL, width, height, 8, 0);    if (!rximg->image) {	free(rximg);	sprintf(RErrorString, "error creating XImage");	return NULL;    }    rximg->image->data = malloc(rximg->image->bytes_per_line*height);    if (!rximg->image->data) {	XDestroyImage(rximg->image);	free(rximg);	sprintf(RErrorString, "out of memory trying to create XImage");	return NULL;    }    #else /* XSHM */        if (!context->attribs->use_shared_memory) {    retry_without_shm:	rximg->is_shared = 0;	rximg->image = XCreateImage(context->dpy, context->visual, depth,				    ZPixmap, 0, NULL, width, height, 8, 0);	if (!rximg->image) {	    free(rximg);	    sprintf(RErrorString, "error creating XImage");	    return NULL;	}	rximg->image->data = malloc(rximg->image->bytes_per_line*height);	if (!rximg->image->data) {	    XDestroyImage(rximg->image);	    free(rximg);	    sprintf(RErrorString, "out of memory trying to create XImage");	    return NULL;	}    } else {	rximg->is_shared = 1;	rximg->image = XShmCreateImage(context->dpy, context->visual, depth,				       ZPixmap, NULL, &rximg->info, width, 				       height);		rximg->info.shmid = shmget(IPC_PRIVATE, 				   rximg->image->bytes_per_line*height,				   IPC_CREAT|0770);	if (rximg->info.shmid < 0) {	    context->attribs->use_shared_memory = 0;	    perror("wrlib:could not allocate shared memory segment:");	    XDestroyImage(rximg->image);	    goto retry_without_shm;	}		rximg->info.shmaddr = shmat(rximg->info.shmid, 0, 0);	if (rximg->info.shmaddr == (void*)-1) {	    context->attribs->use_shared_memory = 0;	    if (shmctl(rximg->info.shmid, IPC_RMID, 0) < 0)		perror("wrlib:shmctl:");	    perror("wrlib:could not allocate shared memory");	    XDestroyImage(rximg->image);	    goto retry_without_shm;	}		shmError = 0;	XSync(context->dpy, False);	oldErrorHandler = XSetErrorHandler(errorHandler);	XShmAttach(context->dpy, &rximg->info);		XSync(context->dpy, False);	XSetErrorHandler(oldErrorHandler);	rximg->image->data = rximg->info.shmaddr;/*	rximg->image->obdata = &(rximg->info);*/	if (shmError) {	    context->attribs->use_shared_memory = 0;	    XDestroyImage(rximg->image);	    if (shmdt(rximg->info.shmaddr) < 0)		perror("wrlib:shmdt:");	    if (shmctl(rximg->info.shmid, IPC_RMID, 0) < 0)		perror("wrlib:shmctl:");	    printf("wrlib:error attaching shared memory segment to XImage\n");	    goto retry_without_shm;	}    }#endif /* XSHM */        return rximg;}