mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 06:34:11 +00:00
Better set memory management.
At the cost of one pointer per set, sets can now be allocated and freed more efficiently (especially since malloc might round things up).
This commit is contained in:
parent
2385cf65c2
commit
b9599a7119
2 changed files with 6 additions and 3 deletions
|
@ -37,8 +37,9 @@
|
|||
//@{
|
||||
|
||||
typedef struct set_s {
|
||||
unsigned size;
|
||||
struct set_s *next; //< private. for ALLOC
|
||||
unsigned *map;
|
||||
unsigned size;
|
||||
unsigned defmap[8];
|
||||
} set_t;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
#define BITS (sizeof (unsigned) * 8)
|
||||
|
||||
set_t *free_sets;
|
||||
set_iter_t *free_set_iters;
|
||||
|
||||
static set_iter_t *
|
||||
|
@ -76,7 +77,7 @@ set_new (void)
|
|||
{
|
||||
set_t *set;
|
||||
|
||||
set = calloc (1, sizeof (set_t));
|
||||
ALLOC (16, set_t, sets, set);
|
||||
set->size = sizeof (set->defmap) * 8;
|
||||
set->map = set->defmap;
|
||||
return set;
|
||||
|
@ -87,7 +88,8 @@ set_delete (set_t *set)
|
|||
{
|
||||
if (set->map != set->defmap)
|
||||
free (set->map);
|
||||
free (set);
|
||||
set->next = free_sets;
|
||||
free_sets = set;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue