mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-05 15:31:16 +00:00
clean up the buffer size calcs a bit
This commit is contained in:
parent
3909176957
commit
ad4f29c6a8
1 changed files with 3 additions and 3 deletions
|
@ -179,9 +179,9 @@ C_Print (const char *fmt, va_list args)
|
||||||
int size;
|
int size;
|
||||||
static int buffer_size;
|
static int buffer_size;
|
||||||
|
|
||||||
size = vsnprintf (buffer, buffer_size, fmt, args);
|
size = vsnprintf (buffer, buffer_size, fmt, args) + 1; // +1 for nul
|
||||||
if (size + 1 > buffer_size) {
|
if (size > buffer_size) {
|
||||||
buffer_size = ((size + 1 + 1024) / 1024) * 1024; // 1k multiples
|
buffer_size = (size + 1023) & ~1023; // 1k multiples
|
||||||
buffer = realloc (buffer, buffer_size);
|
buffer = realloc (buffer, buffer_size);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
Sys_Error ("console: could not allocate %d bytes\n",
|
Sys_Error ("console: could not allocate %d bytes\n",
|
||||||
|
|
Loading…
Reference in a new issue