int char1;
unsigned int char1;
ParsePixels(data, width, height, ncolors, cpp, colorTable, hashtable, pixels)    xpmData *data;    unsigned int width;    unsigned int height;    unsigned int ncolors;    unsigned int cpp;    XpmColor *colorTable;    xpmHashTable *hashtable;    unsigned int **pixels;{    unsigned int *iptr, *iptr2;    unsigned int a, x, y;    if ((height > 0 && width >= SIZE_MAX / height) ||	width * height >= UINT_MAX / sizeof(unsigned int)) 	return XpmNoMemory;#ifndef FOR_MSW    iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height);#else    /*     * special treatment to trick DOS malloc(size_t) where size_t is 16 bit!!     * XpmMalloc is defined to longMalloc(long) and checks the 16 bit boundary     */    iptr2 = (unsigned int *)	XpmMalloc((long) sizeof(unsigned int) * (long) width * (long) height);#endif    if (!iptr2)	return (XpmNoMemory);    iptr = iptr2;    switch (cpp) {    case (1):				/* Optimize for single character					 * colors */	{	    unsigned short colidx[256];	    if (ncolors > 256)		return (XpmFileInvalid);	    bzero((char *)colidx, 256 * sizeof(short));	    for (a = 0; a < ncolors; a++)		colidx[(unsigned char)colorTable[a].string[0]] = a + 1;	    for (y = 0; y < height; y++) {		xpmNextString(data);		for (x = 0; x < width; x++, iptr++) {		    int c = xpmGetC(data);		    if (c > 0 && c < 256 && colidx[c] != 0)			*iptr = colidx[c] - 1;		    else {			XpmFree(iptr2);			return (XpmFileInvalid);		    }		}	    }	}	break;    case (2):				/* Optimize for double character					 * colors */	{/* free all allocated pointers at all exits */#define FREE_CIDX {int f; for (f = 0; f < 256; f++) \if (cidx[f]) XpmFree(cidx[f]);}	    /* array of pointers malloced by need */	    unsigned short *cidx[256];	    int char1;	    bzero((char *)cidx, 256 * sizeof(unsigned short *)); /* init */	    for (a = 0; a < ncolors; a++) {		char1 = colorTable[a].string[0];		if (cidx[char1] == NULL) { /* get new memory */		    cidx[char1] = (unsigned short *)			XpmCalloc(256, sizeof(unsigned short));		    if (cidx[char1] == NULL) { /* new block failed */			FREE_CIDX;			XpmFree(iptr2);			return (XpmNoMemory);		    }		}		cidx[char1][(unsigned char)colorTable[a].string[1]] = a + 1;	    }	    for (y = 0; y < height; y++) {		xpmNextString(data);		for (x = 0; x < width; x++, iptr++) {		    int cc1 = xpmGetC(data);		    if (cc1 > 0 && cc1 < 256) {			int cc2 = xpmGetC(data);			if (cc2 > 0 && cc2 < 256 &&			    cidx[cc1] && cidx[cc1][cc2] != 0)			    *iptr = cidx[cc1][cc2] - 1;			else {			    FREE_CIDX;			    XpmFree(iptr2);			    return (XpmFileInvalid);			}		    } else {			FREE_CIDX;			XpmFree(iptr2);			return (XpmFileInvalid);		    }		}	    }	    FREE_CIDX;	}	break;    default:				/* Non-optimized case of long color					 * names */	{	    char *s;	    char buf[BUFSIZ];	    if (cpp >= sizeof(buf))		return (XpmFileInvalid);	    buf[cpp] = '\0';	    if (USE_HASHTABLE) {		xpmHashAtom *slot;		for (y = 0; y < height; y++) {		    xpmNextString(data);		    for (x = 0; x < width; x++, iptr++) {			for (a = 0, s = buf; a < cpp; a++, s++)			    *s = xpmGetC(data);			slot = xpmHashSlot(hashtable, buf);			if (!*slot) {	/* no color matches */			    XpmFree(iptr2);			    return (XpmFileInvalid);			}			*iptr = HashColorIndex(slot);		    }		}	    } else {		for (y = 0; y < height; y++) {		    xpmNextString(data);		    for (x = 0; x < width; x++, iptr++) {			for (a = 0, s = buf; a < cpp; a++, s++)			    *s = xpmGetC(data);			for (a = 0; a < ncolors; a++)			    if (!strcmp(colorTable[a].string, buf))				break;			if (a == ncolors) {	/* no color matches */			    XpmFree(iptr2);			    return (XpmFileInvalid);			}			*iptr = a;		    }		}	    }	}	break;    }    *pixels = iptr2;    return (XpmSuccess);}