rem: sprintf(RErrorString, "out of memory");
add: RErrorCode = RERR_NOMEMORY;
context: RGetClosestXColor(RContext *context, RColor *color, XColor *retColor){    RErrorString[0] = 0;    if (context->vclass == TrueColor) {	unsigned short rmask, gmask, bmask;	unsigned short roffs, goffs, boffs;	unsigned short *rtable, *gtable, *btable;    	roffs = context->red_offset;	goffs = context->green_offset;	boffs = context->blue_offset;    	rmask = context->visual->red_mask >> roffs;	gmask = context->visual->green_mask >> goffs;	bmask = context->visual->blue_mask >> boffs;		rtable = computeTable(rmask);	gtable = computeTable(gmask);	btable = computeTable(bmask);	retColor->pixel = (rtable[color->red]<<roffs) |	    (rtable[color->green]<<goffs) | (rtable[color->blue]<<boffs);	retColor->red = rtable[color->red] << 8;		retColor->green = rtable[color->green] << 8;	retColor->blue = rtable[color->blue] << 8;	retColor->flags = DoRed|DoGreen|DoBlue;	    } else if (context->vclass == PseudoColor || context->vclass == StaticColor) {	const int cpc=context->attribs->colors_per_channel;	const unsigned short rmask = cpc-1; /* different sizes could be used */	const unsigned short gmask = rmask; /* for r,g,b */	const unsigned short bmask = rmask;	unsigned short *rtable, *gtable, *btable;	const int cpccpc = cpc*cpc;	int index;	rtable = computeTable(rmask);	gtable = computeTable(gmask);	btable = computeTable(bmask);	if (rtable==NULL || gtable==NULL || btable==NULL) {	    sprintf(RErrorString, "out of memory");	    return False;	}	index = rtable[color->red]*cpccpc + gtable[color->green]*cpc 	    + btable[color->blue];	*retColor = context->colors[index];    } else if (context->vclass == GrayScale || context->vclass == StaticGray) {	const int cpc = context->attribs->colors_per_channel;	unsigned short gmask;	unsigned short *table;	int index;	if (context->vclass == StaticGray)	    gmask = (1<<context->depth) - 1; /* use all grays */	else	    gmask  = cpc*cpc*cpc-1;	table = computeTable(gmask);	if (!table)	    return False;	index = table[(color->red*30 + color->green*59 + color->blue*11)/100];		*retColor = context->colors[index];    } else {	sprintf(RErrorString, "internal bug:unsupported visual:%i",		context->vclass);	return False;    }    return True;}