forked from github/server
move static variable cleanup to kernel_done.
clean up some more.
This commit is contained in:
parent
ef5ce04335
commit
d84ed1f89d
|
@ -55,10 +55,6 @@ void game_done(void)
|
||||||
free_functions();
|
free_functions();
|
||||||
free_config();
|
free_config();
|
||||||
free_locales();
|
free_locales();
|
||||||
message_done();
|
|
||||||
equipment_done();
|
|
||||||
reports_done();
|
|
||||||
curses_done();
|
|
||||||
kernel_done();
|
kernel_done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,24 +401,24 @@ building *largestbuilding(const region * r, cmp_building_cb cmp_gt,
|
||||||
|
|
||||||
static const char *forbidden[] = { "t", "te", "tem", "temp", NULL };
|
static const char *forbidden[] = { "t", "te", "tem", "temp", NULL };
|
||||||
// PEASANT: "b", "ba", "bau", "baue", "p", "pe", "pea", "peas"
|
// PEASANT: "b", "ba", "bau", "baue", "p", "pe", "pea", "peas"
|
||||||
|
static int *forbidden_ids;
|
||||||
|
|
||||||
int forbiddenid(int id)
|
int forbiddenid(int id)
|
||||||
{
|
{
|
||||||
static int *forbid = NULL;
|
|
||||||
static size_t len;
|
static size_t len;
|
||||||
size_t i;
|
size_t i;
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
if (!forbid) {
|
if (!forbidden_ids) {
|
||||||
while (forbidden[len])
|
while (forbidden[len])
|
||||||
++len;
|
++len;
|
||||||
forbid = calloc(len, sizeof(int));
|
forbidden_ids = calloc(len, sizeof(int));
|
||||||
for (i = 0; i != len; ++i) {
|
for (i = 0; i != len; ++i) {
|
||||||
forbid[i] = atoi36(forbidden[i]);
|
forbidden_ids[i] = atoi36(forbidden[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i != len; ++i)
|
for (i = 0; i != len; ++i)
|
||||||
if (id == forbid[i])
|
if (id == forbidden_ids[i])
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -739,8 +739,15 @@ void kernel_done(void)
|
||||||
/* calling this function releases memory assigned to static variables, etc.
|
/* calling this function releases memory assigned to static variables, etc.
|
||||||
* calling it is optional, e.g. a release server will most likely not do it.
|
* calling it is optional, e.g. a release server will most likely not do it.
|
||||||
*/
|
*/
|
||||||
|
xml_done();
|
||||||
|
attrib_done();
|
||||||
|
item_done();
|
||||||
|
message_done();
|
||||||
|
equipment_done();
|
||||||
|
reports_done();
|
||||||
|
curses_done();
|
||||||
|
crmessage_done();
|
||||||
translation_done();
|
translation_done();
|
||||||
free_attribs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_STRDUP
|
#ifndef HAVE_STRDUP
|
||||||
|
@ -1079,7 +1086,6 @@ void free_config(void) {
|
||||||
void free_gamedata(void)
|
void free_gamedata(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
free_donations();
|
|
||||||
|
|
||||||
for (i = 0; i != MAXLOCALES; ++i) {
|
for (i = 0; i != MAXLOCALES; ++i) {
|
||||||
if (defaults[i]) {
|
if (defaults[i]) {
|
||||||
|
@ -1087,6 +1093,10 @@ void free_gamedata(void)
|
||||||
defaults[i] = 0;
|
defaults[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
free(forbidden_ids);
|
||||||
|
forbidden_ids = NULL;
|
||||||
|
|
||||||
|
free_donations();
|
||||||
free_factions();
|
free_factions();
|
||||||
free_units();
|
free_units();
|
||||||
free_regions();
|
free_regions();
|
||||||
|
|
|
@ -232,6 +232,7 @@ void equipment_done(void) {
|
||||||
free(eq->name);
|
free(eq->name);
|
||||||
if (eq->spellbook) {
|
if (eq->spellbook) {
|
||||||
spellbook_clear(eq->spellbook);
|
spellbook_clear(eq->spellbook);
|
||||||
|
free(eq->spellbook);
|
||||||
}
|
}
|
||||||
// TODO: items, subsets
|
// TODO: items, subsets
|
||||||
free(eq);
|
free(eq);
|
||||||
|
|
|
@ -518,6 +518,11 @@ static item *icache;
|
||||||
static int icache_size;
|
static int icache_size;
|
||||||
#define ICACHE_MAX 100
|
#define ICACHE_MAX 100
|
||||||
|
|
||||||
|
void item_done(void) {
|
||||||
|
i_freeall(&icache);
|
||||||
|
icache_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void i_free(item * i)
|
void i_free(item * i)
|
||||||
{
|
{
|
||||||
if (icache_size >= ICACHE_MAX) {
|
if (icache_size >= ICACHE_MAX) {
|
||||||
|
|
|
@ -59,6 +59,8 @@ extern "C" {
|
||||||
#define NMF_PLURAL 0x01
|
#define NMF_PLURAL 0x01
|
||||||
#define NMF_APPEARANCE 0x02
|
#define NMF_APPEARANCE 0x02
|
||||||
|
|
||||||
|
void item_done(void);
|
||||||
|
|
||||||
typedef int(*rtype_uchange) (struct unit * user,
|
typedef int(*rtype_uchange) (struct unit * user,
|
||||||
const struct resource_type * rtype, int delta);
|
const struct resource_type * rtype, int delta);
|
||||||
typedef int(*rtype_uget) (const struct unit * user,
|
typedef int(*rtype_uget) (const struct unit * user,
|
||||||
|
|
|
@ -412,6 +412,7 @@ void a_write_orig(struct storage *store, const attrib * attribs, const void *own
|
||||||
WRITE_TOK(store, "end");
|
WRITE_TOK(store, "end");
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_attribs(void) {
|
void attrib_done(void) {
|
||||||
cb_clear(&cb_deprecated);
|
cb_clear(&cb_deprecated);
|
||||||
|
memset(at_hash, 0, sizeof at_hash);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ extern "C" {
|
||||||
int a_read(struct gamedata *data, attrib ** attribs, void *owner);
|
int a_read(struct gamedata *data, attrib ** attribs, void *owner);
|
||||||
void a_write(struct storage *store, const attrib * attribs, const void *owner);
|
void a_write(struct storage *store, const attrib * attribs, const void *owner);
|
||||||
|
|
||||||
void free_attribs(void);
|
void attrib_done(void);
|
||||||
|
|
||||||
#define DEFAULT_AGE NULL
|
#define DEFAULT_AGE NULL
|
||||||
#define DEFAULT_INIT NULL
|
#define DEFAULT_INIT NULL
|
||||||
|
|
|
@ -32,6 +32,15 @@ typedef struct tsf_list {
|
||||||
|
|
||||||
static tsf_list *tostringfs;
|
static tsf_list *tostringfs;
|
||||||
|
|
||||||
|
void crmessage_done(void) {
|
||||||
|
tsf_list **tsp = &tostringfs;
|
||||||
|
while (*tsp) {
|
||||||
|
tsf_list *ts = *tsp;
|
||||||
|
*tsp = ts->next;
|
||||||
|
free(ts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static tostring_f tsf_find(const char *name)
|
static tostring_f tsf_find(const char *name)
|
||||||
{
|
{
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
|
|
|
@ -22,6 +22,8 @@ extern "C" {
|
||||||
struct message;
|
struct message;
|
||||||
struct message_type;
|
struct message_type;
|
||||||
|
|
||||||
|
void crmessage_done(void);
|
||||||
|
|
||||||
typedef int(*tostring_f) (variant data, char *buffer, const void *userdata);
|
typedef int(*tostring_f) (variant data, char *buffer, const void *userdata);
|
||||||
void tsf_register(const char *name, tostring_f fun);
|
void tsf_register(const char *name, tostring_f fun);
|
||||||
/* registers a new type->string-function */
|
/* registers a new type->string-function */
|
||||||
|
|
|
@ -89,6 +89,15 @@ typedef struct xml_reader {
|
||||||
|
|
||||||
static xml_reader *xmlReaders;
|
static xml_reader *xmlReaders;
|
||||||
|
|
||||||
|
void xml_done(void) {
|
||||||
|
xml_reader ** xrp = &xmlReaders;
|
||||||
|
while (*xrp) {
|
||||||
|
xml_reader *xr = *xrp;
|
||||||
|
*xrp = xr->next;
|
||||||
|
free(xr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void xml_register_callback(xml_callback callback)
|
void xml_register_callback(xml_callback callback)
|
||||||
{
|
{
|
||||||
xml_reader *reader = (xml_reader *)malloc(sizeof(xml_reader));
|
xml_reader *reader = (xml_reader *)malloc(sizeof(xml_reader));
|
||||||
|
|
|
@ -21,13 +21,17 @@ extern "C" {
|
||||||
/* new xml functions: */
|
/* new xml functions: */
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
typedef int (*xml_callback) (xmlDocPtr);
|
|
||||||
extern void xml_register_callback(xml_callback callback);
|
typedef int (*xml_callback) (xmlDocPtr);
|
||||||
extern double xml_fvalue(xmlNodePtr node, const char *name, double dflt);
|
|
||||||
extern int xml_ivalue(xmlNodePtr node, const char *name, int dflt);
|
void xml_register_callback(xml_callback callback);
|
||||||
extern bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt);
|
double xml_fvalue(xmlNodePtr node, const char *name, double dflt);
|
||||||
|
int xml_ivalue(xmlNodePtr node, const char *name, int dflt);
|
||||||
|
bool xml_bvalue(xmlNodePtr node, const char *name, bool dflt);
|
||||||
#endif
|
#endif
|
||||||
extern int read_xml(const char *filename, const char *catalog);
|
|
||||||
|
void xml_done(void);
|
||||||
|
int read_xml(const char *filename, const char *catalog);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue