From 0cfc51ea6f050adc04e2324db38175bf454e3c1b Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Mon, 15 Oct 2001 17:12:15 +0000 Subject: [PATCH] mallocs, callocs, and frees changed to qmalloc/qfree git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@924 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 4 ++-- console.c | 2 +- model_brush.c | 8 ++++---- quakeio.c | 16 +++++++++------- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd.c b/cmd.c index a8349082..71f476b7 100644 --- a/cmd.c +++ b/cmd.c @@ -692,7 +692,7 @@ Cmd_CompleteBuildList (char *partial) char **buf; len = strlen(partial); - buf = malloc(sizeofbuf + sizeof (char *)); + buf = qmalloc(sizeofbuf + sizeof (char *)); // Loop through the alias list and print all matches for (cmd = cmd_functions; cmd; cmd = cmd->next) if (!strncasecmp(partial, cmd->name, len)) @@ -780,7 +780,7 @@ Cmd_CompleteAliasBuildList (char *partial) char **buf; len = strlen(partial); - buf = malloc(sizeofbuf + sizeof (char *)); + buf = qmalloc(sizeofbuf + sizeof (char *)); // Loop through the alias list and print all matches for (alias = cmd_alias; alias; alias = alias->next) if (!strncasecmp(partial, alias->name, len)) diff --git a/console.c b/console.c index a834765d..1065d847 100644 --- a/console.c +++ b/console.c @@ -799,6 +799,6 @@ Con_CompleteCommandLine (void) } for (i = 0; i < 3; i++) if (list[i]) - free (list[i]); + qfree (list[i]); } diff --git a/model_brush.c b/model_brush.c index 70eae3a6..81a06f66 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1199,7 +1199,7 @@ winding_t *NewWinding (int points) Host_Error("NewWinding: too many points\n"); size = (int)((winding_t *)0)->points[points]; - w = malloc (size); + w = qmalloc (size); memset (w, 0, size); return w; @@ -1207,7 +1207,7 @@ winding_t *NewWinding (int points) void FreeWinding (winding_t *w) { - free (w); + qfree (w); } /* @@ -1475,7 +1475,7 @@ AllocPortal portal_t *AllocPortal (void) { portal_t *p; - p = malloc(sizeof(portal_t)); + p = qmalloc(sizeof(portal_t)); memset(p, 0, sizeof(portal_t)); p->chain = portalchain; portalchain = p; @@ -1602,7 +1602,7 @@ void Mod_FinalizePortals(void) } FreeWinding(p->winding); } - free(p); + qfree(p); p = pnext; } } diff --git a/quakeio.c b/quakeio.c index 6e475ccb..2610e450 100644 --- a/quakeio.c +++ b/quakeio.c @@ -132,14 +132,15 @@ Qopen (const char *path, const char *mode) } *p = 0; - file = calloc (sizeof (*file), 1); + file = qmalloc (sizeof (*file)); + memset(file, 0, sizeof(*file)); if (!file) return 0; #ifdef HAVE_ZLIB if (zip) { file->gzfile = gzopen (path, m); if (!file->gzfile) { - free (file); + qfree (file); return 0; } } else @@ -147,7 +148,7 @@ Qopen (const char *path, const char *mode) { file->file = fopen (path, m); if (!file->file) { - free (file); + qfree (file); return 0; } } @@ -171,14 +172,15 @@ Qdopen (int fd, const char *mode) *p = 0; - file = calloc (sizeof (*file), 1); + file = qmalloc (sizeof (*file)); + memset(file, 0, sizeof(*file)); if (!file) return 0; #ifdef HAVE_ZLIB if (zip) { file->gzfile = gzdopen (fd, m); if (!file->gzfile) { - free (file); + qfree (file); return 0; } } else @@ -186,7 +188,7 @@ Qdopen (int fd, const char *mode) { file->file = fdopen (fd, m); if (!file->file) { - free (file); + qfree (file); return 0; } } @@ -206,7 +208,7 @@ Qclose (QFile *file) else gzclose (file->gzfile); #endif - free (file); + qfree (file); } int -- 2.39.2