mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
keys.c (Key_SetBinding): Avoid the C++ keyword "new".
pr_cmds.c (PF_normalize, PF_vlen): Likewise. zone.c (Z_TagMalloc, Cache_Move, Cache_TryAlloc): Likewise. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@169 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
73c8c176f0
commit
cc80c805b4
3 changed files with 61 additions and 61 deletions
|
@ -541,7 +541,7 @@ Key_SetBinding
|
||||||
*/
|
*/
|
||||||
void Key_SetBinding (int keynum, char *binding)
|
void Key_SetBinding (int keynum, char *binding)
|
||||||
{
|
{
|
||||||
char *new;
|
char *new_binding;
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (keynum == -1)
|
if (keynum == -1)
|
||||||
|
@ -556,10 +556,10 @@ void Key_SetBinding (int keynum, char *binding)
|
||||||
|
|
||||||
// allocate memory for new binding
|
// allocate memory for new binding
|
||||||
l = Q_strlen (binding);
|
l = Q_strlen (binding);
|
||||||
new = Z_Malloc (l+1);
|
new_binding = (char *) Z_Malloc (l+1);
|
||||||
Q_strcpy (new, binding);
|
Q_strcpy (new_binding, binding);
|
||||||
new[l] = 0;
|
new_binding[l] = 0;
|
||||||
keybindings[keynum] = new;
|
keybindings[keynum] = new_binding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -369,21 +369,21 @@ void PF_normalize (void)
|
||||||
{
|
{
|
||||||
float *value1;
|
float *value1;
|
||||||
vec3_t newvalue;
|
vec3_t newvalue;
|
||||||
float new;
|
float new_temp;
|
||||||
|
|
||||||
value1 = G_VECTOR(OFS_PARM0);
|
value1 = G_VECTOR(OFS_PARM0);
|
||||||
|
|
||||||
new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
|
new_temp = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
|
||||||
new = sqrt(new);
|
new_temp = sqrt(new_temp);
|
||||||
|
|
||||||
if (new == 0)
|
if (new_temp == 0)
|
||||||
newvalue[0] = newvalue[1] = newvalue[2] = 0;
|
newvalue[0] = newvalue[1] = newvalue[2] = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
new = 1/new;
|
new_temp = 1/new_temp;
|
||||||
newvalue[0] = value1[0] * new;
|
newvalue[0] = value1[0] * new_temp;
|
||||||
newvalue[1] = value1[1] * new;
|
newvalue[1] = value1[1] * new_temp;
|
||||||
newvalue[2] = value1[2] * new;
|
newvalue[2] = value1[2] * new_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
VectorCopy (newvalue, G_VECTOR(OFS_RETURN));
|
VectorCopy (newvalue, G_VECTOR(OFS_RETURN));
|
||||||
|
@ -399,14 +399,14 @@ scalar vlen(vector)
|
||||||
void PF_vlen (void)
|
void PF_vlen (void)
|
||||||
{
|
{
|
||||||
float *value1;
|
float *value1;
|
||||||
float new;
|
float new_temp;
|
||||||
|
|
||||||
value1 = G_VECTOR(OFS_PARM0);
|
value1 = G_VECTOR(OFS_PARM0);
|
||||||
|
|
||||||
new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
|
new_temp = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
|
||||||
new = sqrt(new);
|
new_temp = sqrt(new_temp);
|
||||||
|
|
||||||
G_FLOAT(OFS_RETURN) = new;
|
G_FLOAT(OFS_RETURN) = new_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -165,7 +165,7 @@ void *Z_Realloc(void *ptr, int size)
|
||||||
void *Z_TagMalloc (int size, int tag)
|
void *Z_TagMalloc (int size, int tag)
|
||||||
{
|
{
|
||||||
int extra;
|
int extra;
|
||||||
memblock_t *start, *rover, *new, *base;
|
memblock_t *start, *rover, *newblock, *base;
|
||||||
|
|
||||||
if (!tag)
|
if (!tag)
|
||||||
Sys_Error ("Z_TagMalloc: tried to use a 0 tag");
|
Sys_Error ("Z_TagMalloc: tried to use a 0 tag");
|
||||||
|
@ -197,14 +197,14 @@ void *Z_TagMalloc (int size, int tag)
|
||||||
extra = base->size - size;
|
extra = base->size - size;
|
||||||
if (extra > MINFRAGMENT)
|
if (extra > MINFRAGMENT)
|
||||||
{ // there will be a free fragment after the allocated block
|
{ // there will be a free fragment after the allocated block
|
||||||
new = (memblock_t *) ((byte *)base + size );
|
newblock = (memblock_t *) ((byte *)base + size );
|
||||||
new->size = extra;
|
newblock->size = extra;
|
||||||
new->tag = 0; // free block
|
newblock->tag = 0; // free block
|
||||||
new->prev = base;
|
newblock->prev = base;
|
||||||
new->id = ZONEID;
|
newblock->id = ZONEID;
|
||||||
new->next = base->next;
|
newblock->next = base->next;
|
||||||
new->next->prev = new;
|
newblock->next->prev = newblock;
|
||||||
base->next = new;
|
base->next = newblock;
|
||||||
base->size = size;
|
base->size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,19 +596,19 @@ Cache_Move
|
||||||
*/
|
*/
|
||||||
void Cache_Move ( cache_system_t *c)
|
void Cache_Move ( cache_system_t *c)
|
||||||
{
|
{
|
||||||
cache_system_t *new;
|
cache_system_t *new_cs;
|
||||||
|
|
||||||
// we are clearing up space at the bottom, so only allocate it late
|
// we are clearing up space at the bottom, so only allocate it late
|
||||||
new = Cache_TryAlloc (c->size, true);
|
new_cs = Cache_TryAlloc (c->size, true);
|
||||||
if (new)
|
if (new_cs)
|
||||||
{
|
{
|
||||||
// Con_Printf ("cache_move ok\n");
|
// Con_Printf ("cache_move ok\n");
|
||||||
|
|
||||||
Q_memcpy ( new+1, c+1, c->size - sizeof(cache_system_t) );
|
Q_memcpy ( new_cs+1, c+1, c->size - sizeof(cache_system_t) );
|
||||||
new->user = c->user;
|
new_cs->user = c->user;
|
||||||
Q_memcpy (new->name, c->name, sizeof(new->name));
|
Q_memcpy (new_cs->name, c->name, sizeof(new_cs->name));
|
||||||
Cache_Free (c->user, false); //johnfitz -- added second argument
|
Cache_Free (c->user, false); //johnfitz -- added second argument
|
||||||
new->user->data = (void *)(new+1);
|
new_cs->user->data = (void *)(new_cs+1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -701,7 +701,7 @@ Size should already include the header and padding
|
||||||
*/
|
*/
|
||||||
cache_system_t *Cache_TryAlloc (int size, qboolean nobottom)
|
cache_system_t *Cache_TryAlloc (int size, qboolean nobottom)
|
||||||
{
|
{
|
||||||
cache_system_t *cs, *new;
|
cache_system_t *cs, *new_cs;
|
||||||
|
|
||||||
// is the cache completely empty?
|
// is the cache completely empty?
|
||||||
|
|
||||||
|
@ -710,62 +710,62 @@ cache_system_t *Cache_TryAlloc (int size, qboolean nobottom)
|
||||||
if (hunk_size - hunk_high_used - hunk_low_used < size)
|
if (hunk_size - hunk_high_used - hunk_low_used < size)
|
||||||
Sys_Error ("Cache_TryAlloc: %i is greater then free hunk", size);
|
Sys_Error ("Cache_TryAlloc: %i is greater then free hunk", size);
|
||||||
|
|
||||||
new = (cache_system_t *) (hunk_base + hunk_low_used);
|
new_cs = (cache_system_t *) (hunk_base + hunk_low_used);
|
||||||
memset (new, 0, sizeof(*new));
|
memset (new_cs, 0, sizeof(*new_cs));
|
||||||
new->size = size;
|
new_cs->size = size;
|
||||||
|
|
||||||
cache_head.prev = cache_head.next = new;
|
cache_head.prev = cache_head.next = new_cs;
|
||||||
new->prev = new->next = &cache_head;
|
new_cs->prev = new_cs->next = &cache_head;
|
||||||
|
|
||||||
Cache_MakeLRU (new);
|
Cache_MakeLRU (new_cs);
|
||||||
return new;
|
return new_cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// search from the bottom up for space
|
// search from the bottom up for space
|
||||||
|
|
||||||
new = (cache_system_t *) (hunk_base + hunk_low_used);
|
new_cs = (cache_system_t *) (hunk_base + hunk_low_used);
|
||||||
cs = cache_head.next;
|
cs = cache_head.next;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (!nobottom || cs != cache_head.next)
|
if (!nobottom || cs != cache_head.next)
|
||||||
{
|
{
|
||||||
if ( (byte *)cs - (byte *)new >= size)
|
if ( (byte *)cs - (byte *)new_cs >= size)
|
||||||
{ // found space
|
{ // found space
|
||||||
memset (new, 0, sizeof(*new));
|
memset (new_cs, 0, sizeof(*new_cs));
|
||||||
new->size = size;
|
new_cs->size = size;
|
||||||
|
|
||||||
new->next = cs;
|
new_cs->next = cs;
|
||||||
new->prev = cs->prev;
|
new_cs->prev = cs->prev;
|
||||||
cs->prev->next = new;
|
cs->prev->next = new_cs;
|
||||||
cs->prev = new;
|
cs->prev = new_cs;
|
||||||
|
|
||||||
Cache_MakeLRU (new);
|
Cache_MakeLRU (new_cs);
|
||||||
|
|
||||||
return new;
|
return new_cs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// continue looking
|
// continue looking
|
||||||
new = (cache_system_t *)((byte *)cs + cs->size);
|
new_cs = (cache_system_t *)((byte *)cs + cs->size);
|
||||||
cs = cs->next;
|
cs = cs->next;
|
||||||
|
|
||||||
} while (cs != &cache_head);
|
} while (cs != &cache_head);
|
||||||
|
|
||||||
// try to allocate one at the very end
|
// try to allocate one at the very end
|
||||||
if ( hunk_base + hunk_size - hunk_high_used - (byte *)new >= size)
|
if ( hunk_base + hunk_size - hunk_high_used - (byte *)new_cs >= size)
|
||||||
{
|
{
|
||||||
memset (new, 0, sizeof(*new));
|
memset (new_cs, 0, sizeof(*new_cs));
|
||||||
new->size = size;
|
new_cs->size = size;
|
||||||
|
|
||||||
new->next = &cache_head;
|
new_cs->next = &cache_head;
|
||||||
new->prev = cache_head.prev;
|
new_cs->prev = cache_head.prev;
|
||||||
cache_head.prev->next = new;
|
cache_head.prev->next = new_cs;
|
||||||
cache_head.prev = new;
|
cache_head.prev = new_cs;
|
||||||
|
|
||||||
Cache_MakeLRU (new);
|
Cache_MakeLRU (new_cs);
|
||||||
|
|
||||||
return new;
|
return new_cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL; // couldn't allocate
|
return NULL; // couldn't allocate
|
||||||
|
|
Loading…
Reference in a new issue