From fde47d6983e4ed301d59183f50a9a927ef0b72a0 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 13 Dec 2021 09:15:51 +0900 Subject: [PATCH] [quakefs] Clean out some excess memsets There's no point in zeroing out memory that is only going to be overwritten by the loaded file (excess bytes beyond the end of a massaged text file shouldn't be accessed anyway, and the terminating null is still written). --- libs/util/quakefs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 7ca9f8cab..465b8c534 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -1142,11 +1142,11 @@ QFS_LoadFile (QFile *file, int usehunk) //base = QFS_FileBase (path); if (usehunk == 1) - buf = Hunk_AllocName (0, len + 1, base); + buf = Hunk_RawAllocName (qfs_hunk, len + 1, base); else if (usehunk == 2) - buf = Hunk_TempAlloc (0, len + 1); + buf = Hunk_TempAlloc (qfs_hunk, len + 1); else if (usehunk == 0) - buf = calloc (1, len + 1); + buf = malloc (len + 1); else if (usehunk == 3) buf = Cache_Alloc (loadcache, len + 1, base); else @@ -1156,8 +1156,8 @@ QFS_LoadFile (QFile *file, int usehunk) Sys_Error ("QFS_LoadFile: not enough space"); //Sys_Error ("QFS_LoadFile: not enough space for %s", path); + len = Qread (file, buf, len); buf[len] = 0; - Qread (file, buf, len); Qclose (file); free (base);