All pastes #370166 Raw Edit

Mine

public text v1 · immutable
#370166 ·published 2007-02-24 09:23 UTC
rendered paste body

/**
 * @brief Safe (null terminating) vsnprintf implementation
 */
int Q_vsnprintf (char *str, size_t size, const char *format, va_list ap)
{
	int len;

#if defined(_WIN32)
	len = _vsnprintf(str, size, format, ap);
	str[size-1] = '\0';
#ifdef DEBUG
	if (len == -1)
		Com_Printf("Q_vsnprintf: string was truncated - target buffer too small\n");
#endif
#else
	len = vsnprintf(str, size, format, ap);
#ifdef DEBUG
	if ((size_t)len >= size)
		Com_Printf("Q_vsnprintf: string was truncated - target buffer too small\n");
#endif
#endif

	return len;
}