s = (char *) XpmMalloc(strlen(curbuf) + 1);
len = strlen(curbuf) + 1; s = (char *) XpmMalloc(len);
xpmParseColors(data, ncolors, cpp, colorTablePtr, hashtable)    xpmData *data;    unsigned int ncolors;    unsigned int cpp;    XpmColor **colorTablePtr;    xpmHashTable *hashtable;{    unsigned int key = 0, l, a, b;    unsigned int curkey;		/* current color key */    unsigned int lastwaskey;		/* key read */    char buf[BUFSIZ];    char curbuf[BUFSIZ];		/* current buffer */    char **sptr, *s;    XpmColor *color;    XpmColor *colorTable;    char **defaults;    int ErrorStatus;    colorTable = (XpmColor *) XpmCalloc(ncolors, sizeof(XpmColor));    if (!colorTable)	return (XpmNoMemory);    if (!data->format) {		/* XPM 2 or 3 */	for (a = 0, color = colorTable; a < ncolors; a++, color++) {	    xpmNextString(data);	/* skip the line */	    /*	     * read pixel value	     */	    color->string = (char *) XpmMalloc(cpp + 1);	    if (!color->string) {		xpmFreeColorTable(colorTable, ncolors);		return (XpmNoMemory);	    }	    for (b = 0, s = color->string; b < cpp; b++, s++)		*s = xpmGetC(data);	    *s = '\0';	    /*	     * store the string in the hashtable with its color index number	     */	    if (USE_HASHTABLE) {		ErrorStatus =		    xpmHashIntern(hashtable, color->string, HashAtomData(a));		if (ErrorStatus != XpmSuccess) {		    xpmFreeColorTable(colorTable, ncolors);		    return (ErrorStatus);		}	    }	    /*	     * read color keys and values	     */	    defaults = (char **) color;	    curkey = 0;	    lastwaskey = 0;	    *curbuf = '\0';		/* init curbuf */	    while ((l = xpmNextWord(data, buf, BUFSIZ))) {		if (!lastwaskey) {		    for (key = 0, sptr = xpmColorKeys; key < NKEYS; key++,			 sptr++)			if ((strlen(*sptr) == l) && (!strncmp(*sptr, buf, l)))			    break;		}		if (!lastwaskey && key < NKEYS) {	/* open new key */		    if (curkey) {	/* flush string */			s = (char *) XpmMalloc(strlen(curbuf) + 1);			if (!s) {			    xpmFreeColorTable(colorTable, ncolors);			    return (XpmNoMemory);			}			defaults[curkey] = s;			strcpy(s, curbuf);		    }		    curkey = key + 1;	/* set new key  */		    *curbuf = '\0';	/* reset curbuf */		    lastwaskey = 1;		} else {		    if (!curkey) {	/* key without value */			xpmFreeColorTable(colorTable, ncolors);			return (XpmFileInvalid);		    }		    if (!lastwaskey)			strcat(curbuf, " ");	/* append space */		    buf[l] = '\0';		    strcat(curbuf, buf);/* append buf */		    lastwaskey = 0;		}	    }	    if (!curkey) {		/* key without value */		xpmFreeColorTable(colorTable, ncolors);		return (XpmFileInvalid);	    }	    s = defaults[curkey] = (char *) XpmMalloc(strlen(curbuf) + 1);	    if (!s) {		xpmFreeColorTable(colorTable, ncolors);		return (XpmNoMemory);	    }	    strcpy(s, curbuf);	}    } else {				/* XPM 1 */	/* get to the beginning of the first string */	data->Bos = '"';	data->Eos = '\0';	xpmNextString(data);	data->Eos = '"';	for (a = 0, color = colorTable; a < ncolors; a++, color++) {	    /*	     * read pixel value	     */	    color->string = (char *) XpmMalloc(cpp + 1);	    if (!color->string) {		xpmFreeColorTable(colorTable, ncolors);		return (XpmNoMemory);	    }	    for (b = 0, s = color->string; b < cpp; b++, s++)		*s = xpmGetC(data);	    *s = '\0';	    /*	     * store the string in the hashtable with its color index number	     */	    if (USE_HASHTABLE) {		ErrorStatus =		    xpmHashIntern(hashtable, color->string, HashAtomData(a));		if (ErrorStatus != XpmSuccess) {		    xpmFreeColorTable(colorTable, ncolors);		    return (ErrorStatus);		}	    }	    /*	     * read color values	     */	    xpmNextString(data);	/* get to the next string */	    *curbuf = '\0';		/* init curbuf */	    while ((l = xpmNextWord(data, buf, BUFSIZ))) {		if (*curbuf != '\0')		    strcat(curbuf, " ");/* append space */		buf[l] = '\0';		strcat(curbuf, buf);	/* append buf */	    }	    s = (char *) XpmMalloc(strlen(curbuf) + 1);	    if (!s) {		xpmFreeColorTable(colorTable, ncolors);		return (XpmNoMemory);	    }	    strcpy(s, curbuf);	    color->c_color = s;	    *curbuf = '\0';		/* reset curbuf */	    if (a < ncolors - 1)		xpmNextString(data);	/* get to the next string */	}    }    *colorTablePtr = colorTable;    return (XpmSuccess);}