From: molivier Date: Fri, 2 Apr 2004 07:08:54 +0000 (+0000) Subject: Replaced a direct call to "malloc" and "free", and removed several misuses of "Z_Mall... X-Git-Tag: xonotic-v0.1.0preview~5945 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9842ecc109d38eed8bb547787657d2099ae2f999;p=xonotic%2Fdarkplaces.git Replaced a direct call to "malloc" and "free", and removed several misuses of "Z_Malloc" where using the temp mempool was sufficient. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4075 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_particles.c b/cl_particles.c index 790abe05..18ad1fc5 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -88,7 +88,7 @@ void fractalnoise(qbyte *noise, int size, int startgrid) startgrid = bound(0, startgrid, size); amplitude = 0xFFFF; // this gets halved before use - noisebuf = malloc(size*size*sizeof(int)); + noisebuf = Mem_Alloc (tempmempool, size * size * sizeof (*noisebuf)); memset(noisebuf, 0, size*size*sizeof(int)); for (g2 = startgrid;g2;g2 >>= 1) @@ -130,7 +130,7 @@ void fractalnoise(qbyte *noise, int size, int startgrid) for (y = 0;y < size;y++) for (x = 0;x < size;x++) *noise++ = (qbyte) (((n(x,y) - min) * 256) / max); - free(noisebuf); + Mem_Free (noisebuf); #undef n } void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up) diff --git a/cmd.c b/cmd.c index acba1396..2e134d78 100644 --- a/cmd.c +++ b/cmd.c @@ -115,25 +115,25 @@ void Cbuf_InsertText (const char *text) char *temp; int templen; -// copy off any commands still remaining in the exec buffer + // copy off any commands still remaining in the exec buffer templen = cmd_text.cursize; if (templen) { - temp = Z_Malloc (templen); + temp = Mem_Alloc (tempmempool, templen); memcpy (temp, cmd_text.data, templen); SZ_Clear (&cmd_text); } else - temp = NULL; // shut up compiler + temp = NULL; -// add the entire text of the file + // add the entire text of the file Cbuf_AddText (text); -// add the copied off data - if (templen) + // add the copied off data + if (temp != NULL) { SZ_Write (&cmd_text, temp, templen); - Z_Free (temp); + Mem_Free (temp); } } @@ -237,7 +237,7 @@ void Cmd_StuffCmds_f (void) if (!s) return; - text = Z_Malloc (s+1); + text = Mem_Alloc (tempmempool, s + 1); text[0] = 0; for (i=1 ; ivalue = CopyString (cmd); + a->value = Z_Malloc (strlen (cmd) + 1); + strcpy (a->value, cmd); } /* diff --git a/fs.c b/fs.c index 90ba0702..e180f13d 100644 --- a/fs.c +++ b/fs.c @@ -1900,7 +1900,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) if (separator < colon) separator = colon; basepathlength = separator - pattern; - basepath = Z_Malloc(basepathlength + 1); + basepath = Mem_Alloc (tempmempool, basepathlength + 1); if (basepathlength) memcpy(basepath, pattern, basepathlength); basepath[basepathlength] = 0; @@ -2004,7 +2004,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) stringlistfree(liststart); } - Z_Free(basepath); + Mem_Free(basepath); return search; }