mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-28 23:02:31 +00:00
The end of Z_*!!
This after the Z_* stuff hit my profiling list as a top user..
This commit is contained in:
parent
d5ea4bc9bf
commit
29ef95a9b5
24 changed files with 54 additions and 278 deletions
|
@ -38,7 +38,6 @@
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
#define _SOUND_H
|
#define _SOUND_H
|
||||||
|
|
||||||
#include "mathlib.h"
|
#include "mathlib.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
// !!! if this is changed, it much be changed in asm_i386.h too !!!
|
// !!! if this is changed, it much be changed in asm_i386.h too !!!
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -95,14 +95,6 @@ Zone block
|
||||||
|
|
||||||
void Memory_Init (void *buf, int size);
|
void Memory_Init (void *buf, int size);
|
||||||
|
|
||||||
void Z_Free (void *ptr);
|
|
||||||
void *Z_Malloc (int size); // returns 0 filled memory
|
|
||||||
void *Z_TagMalloc (int size, int tag);
|
|
||||||
|
|
||||||
void Z_DumpHeap (void);
|
|
||||||
void Z_CheckHeap (void);
|
|
||||||
int Z_FreeMemory (void);
|
|
||||||
|
|
||||||
void *Hunk_Alloc (int size); // returns 0 filled memory
|
void *Hunk_Alloc (int size); // returns 0 filled memory
|
||||||
void *Hunk_AllocName (int size, char *name);
|
void *Hunk_AllocName (int size, char *name);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
#include "bothdefs.h"
|
#include "bothdefs.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "commdef.h"
|
#include "commdef.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -46,11 +45,11 @@ server_entry_t *SL_Add (server_entry_t *start, char *ip, char *desc) {
|
||||||
server_entry_t *p;
|
server_entry_t *p;
|
||||||
p = start;
|
p = start;
|
||||||
if (!start) { //Nothing at beginning of list, create it
|
if (!start) { //Nothing at beginning of list, create it
|
||||||
start = Z_Malloc(sizeof(server_entry_t));
|
start = malloc(sizeof(server_entry_t));
|
||||||
start->prev = 0;
|
start->prev = 0;
|
||||||
start->next = 0;
|
start->next = 0;
|
||||||
start->server = Z_Malloc(strlen(ip) + 1);
|
start->server = malloc(strlen(ip) + 1);
|
||||||
start->desc = Z_Malloc(strlen(desc) + 1);
|
start->desc = malloc(strlen(desc) + 1);
|
||||||
strcpy(start->server,ip);
|
strcpy(start->server,ip);
|
||||||
strcpy(start->desc,desc);
|
strcpy(start->desc,desc);
|
||||||
return (start);
|
return (start);
|
||||||
|
@ -58,10 +57,10 @@ 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
|
for(p=start;p->next;p=p->next); //Get to end of list
|
||||||
|
|
||||||
p->next = Z_Malloc(sizeof(server_entry_t));
|
p->next = malloc(sizeof(server_entry_t));
|
||||||
p->next->prev = p;
|
p->next->prev = p;
|
||||||
p->next->server = Z_Malloc(strlen(ip) + 1);
|
p->next->server = malloc(strlen(ip) + 1);
|
||||||
p->next->desc = Z_Malloc(strlen(desc) + 1);
|
p->next->desc = malloc(strlen(desc) + 1);
|
||||||
|
|
||||||
strcpy(p->next->server,ip);
|
strcpy(p->next->server,ip);
|
||||||
strcpy(p->next->desc,desc);
|
strcpy(p->next->desc,desc);
|
||||||
|
@ -73,22 +72,22 @@ server_entry_t *SL_Add (server_entry_t *start, char *ip, char *desc) {
|
||||||
server_entry_t *SL_Del(server_entry_t *start, server_entry_t *del) {
|
server_entry_t *SL_Del(server_entry_t *start, server_entry_t *del) {
|
||||||
server_entry_t *n;
|
server_entry_t *n;
|
||||||
if (del == start) {
|
if (del == start) {
|
||||||
Z_Free(start->server);
|
free(start->server);
|
||||||
Z_Free(start->desc);
|
free(start->desc);
|
||||||
n = start->next;
|
n = start->next;
|
||||||
if (n)
|
if (n)
|
||||||
n->prev = 0;
|
n->prev = 0;
|
||||||
Z_Free(start);
|
free(start);
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
Z_Free(del->server);
|
free(del->server);
|
||||||
Z_Free(del->desc);
|
free(del->desc);
|
||||||
if (del->prev)
|
if (del->prev)
|
||||||
del->prev->next = del->next;
|
del->prev->next = del->next;
|
||||||
if (del->next)
|
if (del->next)
|
||||||
del->next->prev = del->prev;
|
del->next->prev = del->prev;
|
||||||
Z_Free(del);
|
free(del);
|
||||||
return (start);
|
return (start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,9 +95,9 @@ server_entry_t *SL_InsB (server_entry_t *start, server_entry_t *place, char *ip,
|
||||||
server_entry_t *new;
|
server_entry_t *new;
|
||||||
server_entry_t *other;
|
server_entry_t *other;
|
||||||
|
|
||||||
new = Z_Malloc(sizeof(server_entry_t));
|
new = malloc(sizeof(server_entry_t));
|
||||||
new->server = Z_Malloc(strlen(ip) + 1);
|
new->server = malloc(strlen(ip) + 1);
|
||||||
new->desc = Z_Malloc(strlen(desc) + 1);
|
new->desc = malloc(strlen(desc) + 1);
|
||||||
strcpy(new->server,ip);
|
strcpy(new->server,ip);
|
||||||
strcpy(new->desc,desc);
|
strcpy(new->desc,desc);
|
||||||
other = place->prev;
|
other = place->prev;
|
||||||
|
@ -160,7 +159,7 @@ server_entry_t *SL_LoadF (FILE *f,server_entry_t *start) { // This could get mes
|
||||||
line[i - 1] = '\0'; // Now we can parse it
|
line[i - 1] = '\0'; // Now we can parse it
|
||||||
if ((st = gettokstart(line,1,' ')) != NULL) {
|
if ((st = gettokstart(line,1,' ')) != NULL) {
|
||||||
len = gettoklen(line,1,' ');
|
len = gettoklen(line,1,' ');
|
||||||
addr = Z_Malloc(len + 1);
|
addr = malloc(len + 1);
|
||||||
strncpy(addr,&line[0],len);
|
strncpy(addr,&line[0],len);
|
||||||
addr[len] = '\0';
|
addr[len] = '\0';
|
||||||
if ((st = gettokstart(line,2,' '))) {
|
if ((st = gettokstart(line,2,' '))) {
|
||||||
|
@ -201,9 +200,9 @@ server_entry_t *SL_LoadF (FILE *f,server_entry_t *start) { // This could get mes
|
||||||
server_entry_t *n;
|
server_entry_t *n;
|
||||||
while (start) {
|
while (start) {
|
||||||
n = start->next;
|
n = start->next;
|
||||||
Z_Free(start->server);
|
free(start->server);
|
||||||
Z_Free(start->desc);
|
free(start->desc);
|
||||||
Z_Free(start);
|
free(start);
|
||||||
start = n;
|
start = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
24
source/cmd.c
24
source/cmd.c
|
@ -33,11 +33,11 @@
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "sizebuf.h"
|
#include "sizebuf.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "commdef.h"
|
#include "commdef.h"
|
||||||
|
#include "zone.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -139,7 +139,7 @@ void Cbuf_InsertText (char *text)
|
||||||
templen = cmd_text.cursize;
|
templen = cmd_text.cursize;
|
||||||
if (templen)
|
if (templen)
|
||||||
{
|
{
|
||||||
temp = Z_Malloc (templen);
|
temp = malloc (templen);
|
||||||
memcpy (temp, cmd_text.data, templen);
|
memcpy (temp, cmd_text.data, templen);
|
||||||
SZ_Clear (&cmd_text);
|
SZ_Clear (&cmd_text);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ void Cbuf_InsertText (char *text)
|
||||||
if (templen)
|
if (templen)
|
||||||
{
|
{
|
||||||
SZ_Write (&cmd_text, temp, templen);
|
SZ_Write (&cmd_text, temp, templen);
|
||||||
Z_Free (temp);
|
free (temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ void Cmd_StuffCmds_f (void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// pull out the commands
|
// pull out the commands
|
||||||
build = Z_Malloc (s+1);
|
build = malloc (s+1);
|
||||||
build[0] = 0;
|
build[0] = 0;
|
||||||
|
|
||||||
for (i=0 ; i<s-1 ; i++)
|
for (i=0 ; i<s-1 ; i++)
|
||||||
|
@ -293,7 +293,7 @@ void Cmd_StuffCmds_f (void)
|
||||||
if (build[0])
|
if (build[0])
|
||||||
Cbuf_InsertText (build);
|
Cbuf_InsertText (build);
|
||||||
|
|
||||||
Z_Free (build);
|
free (build);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -386,7 +386,7 @@ char *CopyString (char *in)
|
||||||
{
|
{
|
||||||
char *out;
|
char *out;
|
||||||
|
|
||||||
out = Z_Malloc (strlen(in)+1);
|
out = malloc (strlen(in)+1);
|
||||||
strcpy (out, in);
|
strcpy (out, in);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -418,14 +418,14 @@ void Cmd_Alias_f (void)
|
||||||
{
|
{
|
||||||
if (!strcmp(s, a->name))
|
if (!strcmp(s, a->name))
|
||||||
{
|
{
|
||||||
Z_Free (a->value);
|
free (a->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!a)
|
if (!a)
|
||||||
{
|
{
|
||||||
a = Z_Malloc (sizeof(cmdalias_t));
|
a = malloc (sizeof(cmdalias_t));
|
||||||
a->next = cmd_alias;
|
a->next = cmd_alias;
|
||||||
cmd_alias = a;
|
cmd_alias = a;
|
||||||
}
|
}
|
||||||
|
@ -468,11 +468,11 @@ void Cmd_UnAlias_f (void)
|
||||||
{
|
{
|
||||||
if (!strcmp(s, a->name))
|
if (!strcmp(s, a->name))
|
||||||
{
|
{
|
||||||
Z_Free (a->value);
|
free (a->value);
|
||||||
prev->next = a->next;
|
prev->next = a->next;
|
||||||
if (a == cmd_alias)
|
if (a == cmd_alias)
|
||||||
cmd_alias = a->next;
|
cmd_alias = a->next;
|
||||||
Z_Free (a);
|
free (a);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prev = a;
|
prev = a;
|
||||||
|
@ -557,7 +557,7 @@ void Cmd_TokenizeString (char *text)
|
||||||
|
|
||||||
// clear the args from the last string
|
// clear the args from the last string
|
||||||
for (i=0 ; i<cmd_argc ; i++)
|
for (i=0 ; i<cmd_argc ; i++)
|
||||||
Z_Free (cmd_argv[i]);
|
free (cmd_argv[i]);
|
||||||
|
|
||||||
cmd_argc = 0;
|
cmd_argc = 0;
|
||||||
cmd_args = NULL;
|
cmd_args = NULL;
|
||||||
|
@ -588,7 +588,7 @@ void Cmd_TokenizeString (char *text)
|
||||||
|
|
||||||
if (cmd_argc < MAX_ARGS)
|
if (cmd_argc < MAX_ARGS)
|
||||||
{
|
{
|
||||||
cmd_argv[cmd_argc] = Z_Malloc (strlen(com_token)+1);
|
cmd_argv[cmd_argc] = malloc (strlen(com_token)+1);
|
||||||
strcpy (cmd_argv[cmd_argc], com_token);
|
strcpy (cmd_argv[cmd_argc], com_token);
|
||||||
cmd_argc++;
|
cmd_argc++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
|
|
||||||
#include "commdef.h"
|
#include "commdef.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "qargs.h"
|
#include "qargs.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
|
@ -195,9 +194,9 @@ void Cvar_Set (cvar_t *var, char *value)
|
||||||
if(var->flags&CVAR_ROM)
|
if(var->flags&CVAR_ROM)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Z_Free (var->string); // free the old value string
|
free (var->string); // free the old value string
|
||||||
|
|
||||||
var->string = Z_Malloc (strlen(value)+1);
|
var->string = malloc (strlen(value)+1);
|
||||||
strcpy (var->string, value);
|
strcpy (var->string, value);
|
||||||
var->value = atof (var->string);
|
var->value = atof (var->string);
|
||||||
|
|
||||||
|
@ -215,9 +214,9 @@ void Cvar_SetROM (cvar_t *var, char *value)
|
||||||
if (!var)
|
if (!var)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Z_Free (var->string); // free the old value string
|
free (var->string); // free the old value string
|
||||||
|
|
||||||
var->string = Z_Malloc (strlen(value)+1);
|
var->string = malloc (strlen(value)+1);
|
||||||
strcpy (var->string, value);
|
strcpy (var->string, value);
|
||||||
var->value = atof (var->string);
|
var->value = atof (var->string);
|
||||||
|
|
||||||
|
@ -413,7 +412,7 @@ void Cvar_Shutdown (void)
|
||||||
{
|
{
|
||||||
next = var->next;
|
next = var->next;
|
||||||
free(var->description);
|
free(var->description);
|
||||||
Z_Free(var->string);
|
free(var->string);
|
||||||
free(var->name);
|
free(var->name);
|
||||||
free(var);
|
free(var);
|
||||||
var = next;
|
var = next;
|
||||||
|
@ -448,7 +447,7 @@ cvar_t *Cvar_Get(char *name, char *string, int cvarflags, char *description)
|
||||||
v->next = cvar_vars;
|
v->next = cvar_vars;
|
||||||
cvar_vars = v;
|
cvar_vars = v;
|
||||||
v->name = strdup(name);
|
v->name = strdup(name);
|
||||||
v->string = Z_Malloc (strlen(string)+1);
|
v->string = malloc (strlen(string)+1);
|
||||||
strcpy (v->string, string);
|
strcpy (v->string, string);
|
||||||
v->flags = cvarflags;
|
v->flags = cvarflags;
|
||||||
v->description = strdup(description);
|
v->description = strdup(description);
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
|
@ -572,13 +571,13 @@ void Key_SetBinding (int keynum, char *binding)
|
||||||
// free old bindings
|
// free old bindings
|
||||||
if (keybindings[keynum])
|
if (keybindings[keynum])
|
||||||
{
|
{
|
||||||
Z_Free (keybindings[keynum]);
|
free (keybindings[keynum]);
|
||||||
keybindings[keynum] = NULL;
|
keybindings[keynum] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate memory for new binding
|
// allocate memory for new binding
|
||||||
l = strlen (binding);
|
l = strlen (binding);
|
||||||
new = Z_Malloc (l+1);
|
new = malloc (l+1);
|
||||||
strcpy (new, binding);
|
strcpy (new, binding);
|
||||||
new[l] = 0;
|
new[l] = 0;
|
||||||
keybindings[keynum] = new;
|
keybindings[keynum] = new;
|
||||||
|
|
|
@ -1242,10 +1242,10 @@ void M_SEdit_Key (int key) {
|
||||||
break;
|
break;
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
c = SL_Get_By_Num(slist,m_multip_cursor);
|
c = SL_Get_By_Num(slist,m_multip_cursor);
|
||||||
Z_Free(c->server);
|
free(c->server);
|
||||||
Z_Free(c->desc);
|
free(c->desc);
|
||||||
c->server = Z_Malloc(strlen(serv) + 1);
|
c->server = malloc(strlen(serv) + 1);
|
||||||
c->desc = Z_Malloc(strlen(desc) + 1);
|
c->desc = malloc(strlen(desc) + 1);
|
||||||
strcpy(c->server,serv);
|
strcpy(c->server,serv);
|
||||||
strcpy(c->desc,desc);
|
strcpy(c->desc,desc);
|
||||||
M_Menu_MultiPlayer_f ();
|
M_Menu_MultiPlayer_f ();
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "quakefs.h"
|
#include "quakefs.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "zone.h"
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "cvar.h"
|
#include "cvar.h"
|
||||||
|
@ -510,7 +509,7 @@ COM_LoadFile (char *path, int usehunk)
|
||||||
else if (usehunk == 2)
|
else if (usehunk == 2)
|
||||||
buf = Hunk_TempAlloc (len+1);
|
buf = Hunk_TempAlloc (len+1);
|
||||||
else if (usehunk == 0)
|
else if (usehunk == 0)
|
||||||
buf = Z_Malloc (len+1);
|
buf = malloc (len+1);
|
||||||
else if (usehunk == 3)
|
else if (usehunk == 3)
|
||||||
buf = Cache_Alloc (loadcache, len+1, base);
|
buf = Cache_Alloc (loadcache, len+1, base);
|
||||||
else if (usehunk == 4)
|
else if (usehunk == 4)
|
||||||
|
@ -605,7 +604,7 @@ COM_LoadPackFile (char *packfile)
|
||||||
if (numpackfiles > MAX_FILES_IN_PACK)
|
if (numpackfiles > MAX_FILES_IN_PACK)
|
||||||
Sys_Error ("%s has %i files", packfile, numpackfiles);
|
Sys_Error ("%s has %i files", packfile, numpackfiles);
|
||||||
|
|
||||||
newfiles = Z_Malloc (numpackfiles * sizeof(packfile_t));
|
newfiles = malloc (numpackfiles * sizeof(packfile_t));
|
||||||
|
|
||||||
fseek (packhandle, header.dirofs, SEEK_SET);
|
fseek (packhandle, header.dirofs, SEEK_SET);
|
||||||
fread (info, 1, header.dirlen, packhandle);
|
fread (info, 1, header.dirlen, packhandle);
|
||||||
|
@ -619,7 +618,7 @@ COM_LoadPackFile (char *packfile)
|
||||||
newfiles[i].filelen = LittleLong(info[i].filelen);
|
newfiles[i].filelen = LittleLong(info[i].filelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
pack = Z_Malloc (sizeof (pack_t));
|
pack = malloc (sizeof (pack_t));
|
||||||
strcpy (pack->filename, packfile);
|
strcpy (pack->filename, packfile);
|
||||||
pack->handle = packhandle;
|
pack->handle = packhandle;
|
||||||
pack->numfiles = numpackfiles;
|
pack->numfiles = numpackfiles;
|
||||||
|
@ -721,7 +720,7 @@ COM_LoadGameDirectory(char *dir)
|
||||||
if (!pak) {
|
if (!pak) {
|
||||||
Sys_Error(va("Bad pakfile %s!!", pakfiles[i]));
|
Sys_Error(va("Bad pakfile %s!!", pakfiles[i]));
|
||||||
} else {
|
} else {
|
||||||
search = Z_Malloc (sizeof(searchpath_t));
|
search = malloc (sizeof(searchpath_t));
|
||||||
search->pack = pak;
|
search->pack = pak;
|
||||||
search->next = com_searchpaths;
|
search->next = com_searchpaths;
|
||||||
com_searchpaths = search;
|
com_searchpaths = search;
|
||||||
|
@ -761,7 +760,7 @@ COM_AddDirectory (char *dir)
|
||||||
//
|
//
|
||||||
// add the directory to the search path
|
// add the directory to the search path
|
||||||
//
|
//
|
||||||
search = Z_Malloc (sizeof(searchpath_t));
|
search = malloc (sizeof(searchpath_t));
|
||||||
strcpy (search->filename, dir);
|
strcpy (search->filename, dir);
|
||||||
search->next = com_searchpaths;
|
search->next = com_searchpaths;
|
||||||
com_searchpaths = search;
|
com_searchpaths = search;
|
||||||
|
@ -821,11 +820,11 @@ COM_Gamedir (char *dir)
|
||||||
if (com_searchpaths->pack)
|
if (com_searchpaths->pack)
|
||||||
{
|
{
|
||||||
fclose (com_searchpaths->pack->handle);
|
fclose (com_searchpaths->pack->handle);
|
||||||
Z_Free (com_searchpaths->pack->files);
|
free (com_searchpaths->pack->files);
|
||||||
Z_Free (com_searchpaths->pack);
|
free (com_searchpaths->pack);
|
||||||
}
|
}
|
||||||
next = com_searchpaths->next;
|
next = com_searchpaths->next;
|
||||||
Z_Free (com_searchpaths);
|
free (com_searchpaths);
|
||||||
com_searchpaths = next;
|
com_searchpaths = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,7 @@ void SV_Serverinfo_f (void)
|
||||||
var = Cvar_FindVar (Cmd_Argv(1));
|
var = Cvar_FindVar (Cmd_Argv(1));
|
||||||
if (var)
|
if (var)
|
||||||
{
|
{
|
||||||
Z_Free (var->string); // free the old value string
|
free (var->string); // free the old value string
|
||||||
var->string = CopyString (Cmd_Argv(2));
|
var->string = CopyString (Cmd_Argv(2));
|
||||||
var->value = atof (var->string);
|
var->value = atof (var->string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include "bspfile.h" // needed by: glquake.h
|
#include "bspfile.h" // needed by: glquake.h
|
||||||
#include "vid.h"
|
#include "vid.h"
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "zone.h" // needed by: client.h, gl_model.h
|
|
||||||
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
#include "mathlib.h" // needed by: protocol.h, render.h, client.h,
|
||||||
// modelgen.h, glmodel.h
|
// modelgen.h, glmodel.h
|
||||||
#include "wad.h"
|
#include "wad.h"
|
||||||
|
|
|
@ -306,7 +306,7 @@ VID_InitModes(void)
|
||||||
|
|
||||||
/* Get complete information on all modes */
|
/* Get complete information on all modes */
|
||||||
num_modes = vga_lastmodenumber()+1;
|
num_modes = vga_lastmodenumber()+1;
|
||||||
modes = Z_Malloc(num_modes * sizeof(vga_modeinfo));
|
modes = malloc(num_modes * sizeof(vga_modeinfo));
|
||||||
for (i=0 ; i<num_modes ; i++) {
|
for (i=0 ; i<num_modes ; i++) {
|
||||||
if (vga_hasmode(i)) {
|
if (vga_hasmode(i)) {
|
||||||
memcpy(&modes[i], vga_getmodeinfo(i),
|
memcpy(&modes[i], vga_getmodeinfo(i),
|
||||||
|
|
199
source/zone.c
199
source/zone.c
|
@ -81,204 +81,6 @@ all big things are allocated on the hunk.
|
||||||
|
|
||||||
memzone_t *mainzone;
|
memzone_t *mainzone;
|
||||||
|
|
||||||
void Z_ClearZone (memzone_t *zone, int size);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Z_ClearZone
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
void Z_ClearZone (memzone_t *zone, int size)
|
|
||||||
{
|
|
||||||
memblock_t *block;
|
|
||||||
|
|
||||||
// set the entire zone to one free block
|
|
||||||
|
|
||||||
zone->blocklist.next = zone->blocklist.prev = block =
|
|
||||||
(memblock_t *)( (byte *)zone + sizeof(memzone_t) );
|
|
||||||
zone->blocklist.tag = 1; // in use block
|
|
||||||
zone->blocklist.id = 0;
|
|
||||||
zone->blocklist.size = 0;
|
|
||||||
zone->rover = block;
|
|
||||||
|
|
||||||
block->prev = block->next = &zone->blocklist;
|
|
||||||
block->tag = 0; // free block
|
|
||||||
block->id = ZONEID;
|
|
||||||
block->size = size - sizeof(memzone_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Z_Free
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
void Z_Free (void *ptr)
|
|
||||||
{
|
|
||||||
memblock_t *block, *other;
|
|
||||||
|
|
||||||
if (!ptr)
|
|
||||||
Sys_Error ("Z_Free: NULL pointer");
|
|
||||||
|
|
||||||
block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t));
|
|
||||||
if (block->id != ZONEID)
|
|
||||||
Sys_Error ("Z_Free: freed a pointer without ZONEID");
|
|
||||||
if (block->tag == 0)
|
|
||||||
Sys_Error ("Z_Free: freed a freed pointer");
|
|
||||||
|
|
||||||
block->tag = 0; // mark as free
|
|
||||||
|
|
||||||
other = block->prev;
|
|
||||||
if (!other->tag)
|
|
||||||
{ // merge with previous free block
|
|
||||||
other->size += block->size;
|
|
||||||
other->next = block->next;
|
|
||||||
other->next->prev = other;
|
|
||||||
if (block == mainzone->rover)
|
|
||||||
mainzone->rover = other;
|
|
||||||
block = other;
|
|
||||||
}
|
|
||||||
|
|
||||||
other = block->next;
|
|
||||||
if (!other->tag)
|
|
||||||
{ // merge the next free block onto the end
|
|
||||||
block->size += other->size;
|
|
||||||
block->next = other->next;
|
|
||||||
block->next->prev = block;
|
|
||||||
if (other == mainzone->rover)
|
|
||||||
mainzone->rover = block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Z_Malloc
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
void *Z_Malloc (int size)
|
|
||||||
{
|
|
||||||
void *buf;
|
|
||||||
|
|
||||||
Z_CheckHeap (); // DEBUG
|
|
||||||
buf = Z_TagMalloc (size, 1);
|
|
||||||
if (!buf)
|
|
||||||
Sys_Error ("Z_Malloc: failed on allocation of %i bytes",size);
|
|
||||||
memset (buf, 0, size);
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *Z_TagMalloc (int size, int tag)
|
|
||||||
{
|
|
||||||
int extra;
|
|
||||||
memblock_t *start, *rover, *new, *base;
|
|
||||||
|
|
||||||
if (!tag)
|
|
||||||
Sys_Error ("Z_TagMalloc: tried to use a 0 tag");
|
|
||||||
|
|
||||||
//
|
|
||||||
// scan through the block list looking for the first free block
|
|
||||||
// of sufficient size
|
|
||||||
//
|
|
||||||
size += sizeof(memblock_t); // account for size of block header
|
|
||||||
size += 4; // space for memory trash tester
|
|
||||||
size = (size + 7) & ~7; // align to 8-byte boundary
|
|
||||||
|
|
||||||
base = rover = mainzone->rover;
|
|
||||||
start = base->prev;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (rover == start) // scaned all the way around the list
|
|
||||||
return NULL;
|
|
||||||
if (rover->tag)
|
|
||||||
base = rover = rover->next;
|
|
||||||
else
|
|
||||||
rover = rover->next;
|
|
||||||
} while (base->tag || base->size < size);
|
|
||||||
|
|
||||||
//
|
|
||||||
// found a block big enough
|
|
||||||
//
|
|
||||||
extra = base->size - size;
|
|
||||||
if (extra > MINFRAGMENT)
|
|
||||||
{ // there will be a free fragment after the allocated block
|
|
||||||
new = (memblock_t *) ((byte *)base + size );
|
|
||||||
new->size = extra;
|
|
||||||
new->tag = 0; // free block
|
|
||||||
new->prev = base;
|
|
||||||
new->id = ZONEID;
|
|
||||||
new->next = base->next;
|
|
||||||
new->next->prev = new;
|
|
||||||
base->next = new;
|
|
||||||
base->size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
base->tag = tag; // no longer a free block
|
|
||||||
|
|
||||||
mainzone->rover = base->next; // next allocation will start looking here
|
|
||||||
|
|
||||||
base->id = ZONEID;
|
|
||||||
|
|
||||||
// marker for memory trash testing
|
|
||||||
*(int *)((byte *)base + base->size - 4) = ZONEID;
|
|
||||||
|
|
||||||
return (void *) ((byte *)base + sizeof(memblock_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Z_Print
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
void Z_Print (memzone_t *zone)
|
|
||||||
{
|
|
||||||
memblock_t *block;
|
|
||||||
|
|
||||||
Con_Printf ("zone size: %i location: %p\n",mainzone->size,mainzone);
|
|
||||||
|
|
||||||
for (block = zone->blocklist.next ; ; block = block->next)
|
|
||||||
{
|
|
||||||
Con_Printf ("block:%p size:%7i tag:%3i\n",
|
|
||||||
block, block->size, block->tag);
|
|
||||||
|
|
||||||
if (block->next == &zone->blocklist)
|
|
||||||
break; // all blocks have been hit
|
|
||||||
if ( (byte *)block + block->size != (byte *)block->next)
|
|
||||||
Con_Printf ("ERROR: block size does not touch the next block\n");
|
|
||||||
if ( block->next->prev != block)
|
|
||||||
Con_Printf ("ERROR: next block doesn't have proper back link\n");
|
|
||||||
if (!block->tag && !block->next->tag)
|
|
||||||
Con_Printf ("ERROR: two consecutive free blocks\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
========================
|
|
||||||
Z_CheckHeap
|
|
||||||
========================
|
|
||||||
*/
|
|
||||||
void Z_CheckHeap (void)
|
|
||||||
{
|
|
||||||
memblock_t *block;
|
|
||||||
|
|
||||||
for (block = mainzone->blocklist.next ; ; block = block->next)
|
|
||||||
{
|
|
||||||
if (block->next == &mainzone->blocklist)
|
|
||||||
break; // all blocks have been hit
|
|
||||||
if ( (byte *)block + block->size != (byte *)block->next)
|
|
||||||
Sys_Error ("Z_CheckHeap: block size does not touch the next block\n");
|
|
||||||
if ( block->next->prev != block)
|
|
||||||
Sys_Error ("Z_CheckHeap: next block doesn't have proper back link\n");
|
|
||||||
if (!block->tag && !block->next->tag)
|
|
||||||
Sys_Error ("Z_CheckHeap: two consecutive free blocks\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#define HUNK_SENTINAL 0x1df001ed
|
#define HUNK_SENTINAL 0x1df001ed
|
||||||
|
@ -953,6 +755,5 @@ void Memory_Init (void *buf, int size)
|
||||||
Sys_Error ("Memory_Init: you must specify a size in KB after -zone");
|
Sys_Error ("Memory_Init: you must specify a size in KB after -zone");
|
||||||
}
|
}
|
||||||
mainzone = Hunk_AllocName ( zonesize, "zone" );
|
mainzone = Hunk_AllocName ( zonesize, "zone" );
|
||||||
Z_ClearZone (mainzone, zonesize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue