This commit is contained in:
jl777
2019-02-05 21:04:19 -11:00
parent ef94a1d13d
commit 022a5903b8
25 changed files with 933 additions and 579 deletions

View File

@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <curses.h>
#include <memory.h>
#include "rogue.h"
#ifdef MASTER
@@ -81,19 +82,50 @@ _free_list(THING **ptr)
* Free up an item
*/
int32_t itemcounter;
THING *thingptrs[100000];
int32_t numptrs;
void
discard(THING *item)
{
#ifdef MASTER
total--;
#endif
if ( 0 )
{
int32_t i;
for (i=0; i<numptrs; i++)
if ( item == thingptrs[i] )
{
thingptrs[i] = thingptrs[--numptrs];
thingptrs[numptrs] = 0;
break;
}
}
itemcounter--;
free((char *) item);
}
void garbage_collect()
{
return;
int32_t i;
fprintf(stderr,"numptrs.%d free them\n",numptrs);
for (i=0; i<numptrs; i++)
{
//fprintf(stderr,"%p _t_type.%d otype.%d (%c)\n",thingptrs[i],thingptrs[i]->_t._t_type,thingptrs[i]->o_type,thingptrs[i]->o_type);
free(thingptrs[i]);
}
memset(thingptrs,0,sizeof(thingptrs));
numptrs = 0;
}
/*
* new_item
* Get a new item with a specified size
*/
THING *
new_item(void)
{
@@ -107,6 +139,12 @@ new_item(void)
#else
item = (THING *)calloc(1, sizeof *item);
#endif
if ( 0 )
{
thingptrs[numptrs++] = item;
if ( (++itemcounter % 100) == 0 )
fprintf(stderr,"itemcounter.%d\n",itemcounter);
}
item->l_next = NULL;
item->l_prev = NULL;
return item;