XP_BZERO(attrStruct, sizeof(DIR_Attribute));
memset(attrStruct, 0, sizeof(DIR_Attribute));
static nsresult DIR_AddCustomAttribute(DIR_Server *server, const char *attrName, char *jsAttr){	nsresult status = NS_OK;	char *jsCompleteAttr = nsnull;	char *jsAttrForTokenizing = jsAttr;	DIR_AttributeId id;	status = DIR_AttributeNameToId(server, attrName, &id);	/* If the string they gave us doesn't have a ':' in it, assume it's one or more	 * attributes without a pretty name. So find the default pretty name, and generate	 * a "complete" string to use for tokenizing.	 */	if (NS_SUCCEEDED(status) && !PL_strchr(jsAttr, ':'))	{		const char *defaultPrettyName = DIR_GetAttributeName (server, id);		if (defaultPrettyName)		{			jsCompleteAttr = PR_smprintf ("%s:%s", defaultPrettyName, jsAttr);			if (jsCompleteAttr)				jsAttrForTokenizing = jsCompleteAttr;			else				status = NS_ERROR_OUT_OF_MEMORY;		}	}	if (NS_SUCCEEDED(status))	{        char *scratchAttr = nsCRT::strdup(jsAttrForTokenizing);		DIR_Attribute *attrStruct = (DIR_Attribute*) PR_Malloc(sizeof(DIR_Attribute));		if (!server->customAttributes)			server->customAttributes = new nsVoidArray();		if (attrStruct && server->customAttributes && scratchAttr)		{			char *attrToken = nsnull;			PRUint32 attrCount = 0;			XP_BZERO(attrStruct, sizeof(DIR_Attribute));			/* Try to pull out the pretty name into the struct */			attrStruct->id = id;            attrStruct->prettyName = nsCRT::strdup(XP_STRTOK(scratchAttr, ":")); 			/* Count up the attribute names */			while ((attrToken = XP_STRTOK(nsnull, ", ")) != nsnull)				attrCount++;			/* Pull the attribute names into the struct */			PL_strcpy(scratchAttr, jsAttrForTokenizing);			XP_STRTOK(scratchAttr, ":"); 			attrStruct->attrNames = (char**) PR_Malloc((attrCount + 1) * sizeof(char*));			if (attrStruct->attrNames)			{				PRInt32 i = 0;				while ((attrToken = XP_STRTOK(nsnull, ", ")) != nsnull)                    attrStruct->attrNames[i++] = nsCRT::strdup(attrToken);				attrStruct->attrNames[i] = nsnull; /* null-terminate the array */			}			if (NS_SUCCEEDED(status)) /* status is always NS_OK! */				server->customAttributes->AppendElement(attrStruct);			else				DIR_DeleteAttribute (attrStruct);			PR_Free(scratchAttr);		}		else 			status = NS_ERROR_OUT_OF_MEMORY;	}	if (jsCompleteAttr)		PR_smprintf_free(jsCompleteAttr);	return status;}