From 750457b3689729be5f867a35fc6620ac0af2ce1b Mon Sep 17 00:00:00 2001 From: "Zephaniah E. Hull" Date: Thu, 29 Jun 2000 23:30:21 +0000 Subject: [PATCH] Clean up after myself in the Z_* purge.. --- include/zone.h | 1 + source/cl_slist.c | 6 +++--- source/cmd.c | 2 +- source/cvar.c | 4 ++-- source/dirent.c | 2 +- source/qargs.c | 4 ++-- source/quakefs.c | 12 ++++++------ source/screen.c | 2 +- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/zone.h b/include/zone.h index e93256a..d2a2332 100644 --- a/include/zone.h +++ b/include/zone.h @@ -27,6 +27,7 @@ */ #ifndef _ZONE_H #define _ZONE_H + /* memory allocation diff --git a/source/cl_slist.c b/source/cl_slist.c index 5ffbf01..a5e38ec 100644 --- a/source/cl_slist.c +++ b/source/cl_slist.c @@ -45,7 +45,7 @@ server_entry_t *SL_Add (server_entry_t *start, char *ip, char *desc) { server_entry_t *p; p = start; if (!start) { //Nothing at beginning of list, create it - start = malloc(sizeof(server_entry_t)); + start = calloc(1, sizeof(server_entry_t)); start->prev = 0; start->next = 0; start->server = malloc(strlen(ip) + 1); @@ -57,7 +57,7 @@ server_entry_t *SL_Add (server_entry_t *start, char *ip, char *desc) { for(p=start;p->next;p=p->next); //Get to end of list - p->next = malloc(sizeof(server_entry_t)); + p->next = calloc(1, sizeof(server_entry_t)); p->next->prev = p; p->next->server = malloc(strlen(ip) + 1); p->next->desc = malloc(strlen(desc) + 1); @@ -95,7 +95,7 @@ server_entry_t *SL_InsB (server_entry_t *start, server_entry_t *place, char *ip, server_entry_t *new; server_entry_t *other; - new = malloc(sizeof(server_entry_t)); + new = calloc(1, sizeof(server_entry_t)); new->server = malloc(strlen(ip) + 1); new->desc = malloc(strlen(desc) + 1); strcpy(new->server,ip); diff --git a/source/cmd.c b/source/cmd.c index 8c0b9ff..f740999 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -425,7 +425,7 @@ void Cmd_Alias_f (void) if (!a) { - a = malloc (sizeof(cmdalias_t)); + a = calloc (1, sizeof(cmdalias_t)); a->next = cmd_alias; cmd_alias = a; } diff --git a/source/cvar.c b/source/cvar.c index df7e476..6dd6ee3 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -96,7 +96,7 @@ void Cvar_Alias_Get (char *name, cvar_t *cvar) var = Cvar_FindAlias(name); if (!var) { - alias = (cvar_alias_t *) malloc(sizeof(cvar_alias_t)); + alias = (cvar_alias_t *) calloc(1, sizeof(cvar_alias_t)); alias->next = calias_vars; calias_vars = alias; alias->name = strdup(name); @@ -442,7 +442,7 @@ cvar_t *Cvar_Get(char *name, char *string, int cvarflags, char *description) v = Cvar_FindVar(name); if (!v) { - v = (cvar_t *) malloc(sizeof(cvar_t)); + v = (cvar_t *) calloc(1, sizeof(cvar_t)); // Cvar doesn't exist, so we create it v->next = cvar_vars; cvar_vars = v; diff --git a/source/dirent.c b/source/dirent.c index 137aa88..edd9a9e 100644 --- a/source/dirent.c +++ b/source/dirent.c @@ -69,7 +69,7 @@ opendir (const char *szPath) /* Allocate enough space to store DIR structure and the complete * directory path given. */ - nd = (DIR *) malloc (sizeof (DIR) + strlen (szPath) + strlen (SLASH) + + nd = (DIR *) calloc (1, sizeof (DIR) + strlen (szPath) + strlen (SLASH) + strlen (SUFFIX)); if (!nd) diff --git a/source/qargs.c b/source/qargs.c index 11e6138..d912591 100644 --- a/source/qargs.c +++ b/source/qargs.c @@ -96,7 +96,7 @@ void COM_InitArgv (int argc, char **argv) safe = false; - largv = (char**)malloc ((argc + NUM_SAFE_ARGVS + 1) * sizeof (char**)); + largv = (char**)calloc (1, (argc + NUM_SAFE_ARGVS + 1) * sizeof (char**)); for (com_argc=0, len=0 ; com_argc < argc ; com_argc++) { @@ -107,7 +107,7 @@ void COM_InitArgv (int argc, char **argv) len += strlen (argv[com_argc]) + 1; } - com_cmdline = (char*)malloc (len+1); // need strlen(com_cmdline)+2 + com_cmdline = (char*)calloc (1, len+1); // need strlen(com_cmdline)+2 com_cmdline[0] = 0; if (len) { for (i=1; i < argc; i++) diff --git a/source/quakefs.c b/source/quakefs.c index 46e58b6..1bac15b 100644 --- a/source/quakefs.c +++ b/source/quakefs.c @@ -509,7 +509,7 @@ COM_LoadFile (char *path, int usehunk) else if (usehunk == 2) buf = Hunk_TempAlloc (len+1); else if (usehunk == 0) - buf = malloc (len+1); + buf = calloc (1, len+1); else if (usehunk == 3) buf = Cache_Alloc (loadcache, len+1, base); else if (usehunk == 4) @@ -604,7 +604,7 @@ COM_LoadPackFile (char *packfile) if (numpackfiles > MAX_FILES_IN_PACK) Sys_Error ("%s has %i files", packfile, numpackfiles); - newfiles = malloc (numpackfiles * sizeof(packfile_t)); + newfiles = calloc (1, numpackfiles * sizeof(packfile_t)); fseek (packhandle, header.dirofs, SEEK_SET); fread (info, 1, header.dirlen, packhandle); @@ -618,7 +618,7 @@ COM_LoadPackFile (char *packfile) newfiles[i].filelen = LittleLong(info[i].filelen); } - pack = malloc (sizeof (pack_t)); + pack = calloc (1, sizeof (pack_t)); strcpy (pack->filename, packfile); pack->handle = packhandle; pack->numfiles = numpackfiles; @@ -676,7 +676,7 @@ COM_LoadGameDirectory(char *dir) Con_DPrintf ("COM_LoadGameDirectory (\"%s\")\n", dir); - pakfiles = malloc(FBLOCK_SIZE * sizeof(char *)); + pakfiles = calloc(1, FBLOCK_SIZE * sizeof(char *)); bufsize += FBLOCK_SIZE; if (!pakfiles) goto COM_LoadGameDirectory_free; @@ -720,7 +720,7 @@ COM_LoadGameDirectory(char *dir) if (!pak) { Sys_Error(va("Bad pakfile %s!!", pakfiles[i])); } else { - search = malloc (sizeof(searchpath_t)); + search = calloc (1, sizeof(searchpath_t)); search->pack = pak; search->next = com_searchpaths; com_searchpaths = search; @@ -760,7 +760,7 @@ COM_AddDirectory (char *dir) // // add the directory to the search path // - search = malloc (sizeof(searchpath_t)); + search = calloc (1, sizeof(searchpath_t)); strcpy (search->filename, dir); search->next = com_searchpaths; com_searchpaths = search; diff --git a/source/screen.c b/source/screen.c index 1668b5b..35f0908 100644 --- a/source/screen.c +++ b/source/screen.c @@ -869,7 +869,7 @@ void SCR_RSShot_f (void) fracw = (float)vid.width / (float)w; frach = (float)vid.height / (float)h; - newbuf = malloc(w*h); + newbuf = calloc(1, w*h); for (y = 0; y < h; y++) { dest = newbuf + (w * y);