mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Allow freeing of typechains.
This commit is contained in:
parent
1fe031e8cb
commit
400abe7fce
2 changed files with 37 additions and 0 deletions
|
@ -74,6 +74,7 @@ typedef struct type_s {
|
|||
struct class_s *class;
|
||||
} t;
|
||||
struct type_s *next;
|
||||
int freeable;
|
||||
} type_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -128,6 +129,7 @@ extern struct symtab_s *quaternion_struct;
|
|||
struct dstring_s;
|
||||
|
||||
type_t *new_type (void);
|
||||
void free_type (type_t *type);
|
||||
|
||||
/** Append a type to the end of a type chain.
|
||||
|
||||
|
|
|
@ -117,9 +117,43 @@ new_type (void)
|
|||
{
|
||||
type_t *type;
|
||||
ALLOC (1024, type_t, types, type);
|
||||
type->freeable = 1;
|
||||
return type;
|
||||
}
|
||||
|
||||
void
|
||||
free_type (type_t *type)
|
||||
{
|
||||
if (!type || !type->freeable)
|
||||
return;
|
||||
switch (type->type) {
|
||||
case ev_void:
|
||||
case ev_string:
|
||||
case ev_float:
|
||||
case ev_vector:
|
||||
case ev_entity:
|
||||
case ev_type_count:
|
||||
case ev_quat:
|
||||
case ev_integer:
|
||||
case ev_short:
|
||||
break;
|
||||
case ev_field:
|
||||
case ev_pointer:
|
||||
free_type (type->t.fldptr.type);
|
||||
break;
|
||||
case ev_func:
|
||||
free_type (type->t.func.type);
|
||||
break;
|
||||
case ev_invalid:
|
||||
if (type->ty == ty_array)
|
||||
free_type (type->t.array.type);
|
||||
break;
|
||||
}
|
||||
memset (type, 0, sizeof (type));
|
||||
type->next = free_types;
|
||||
free_types = type;
|
||||
}
|
||||
|
||||
type_t *
|
||||
append_type (type_t *type, type_t *new)
|
||||
{
|
||||
|
@ -226,6 +260,7 @@ find_type (type_t *type)
|
|||
// allocate a new one
|
||||
check = new_type ();
|
||||
*check = *type;
|
||||
check->freeable = 0;
|
||||
|
||||
chain_type (check);
|
||||
|
||||
|
|
Loading…
Reference in a new issue