All pastes #460225 Raw Edit

Someone

public text v1 · immutable
#460225 ·published 2007-04-26 22:50 UTC
rendered paste body
/*
=================
PF_strzone

ZQ_QC_STRINGS
string newstr (string str [, float size])

The 'size' parameter is not QSG but an MVDSV extension
=================
*/

void PF_strzone (void)
{
	char *s;
	int i, size;

	s = G_STRING(OFS_PARM0);

	for (i = 0; i < MAX_PRSTR; i++)
	{
		if (!pr_newstrtbl[i] || pr_newstrtbl[i] == pr_strings)
			break;
	}

	if (i == MAX_PRSTR)
		PR_RunError("strzone: out of string memory");

	size = strlen(s) + 1;
	if (pr_argc == 2 && (int) G_FLOAT(OFS_PARM1) > size)
		size = (int) G_FLOAT(OFS_PARM1);

	pr_newstrtbl[i] = (char *) Q_malloc(size);
	strlcpy(pr_newstrtbl[i], s, size);

	G_INT(OFS_RETURN) = -(i+MAX_PRSTR);
}