forked from github/server
misc. memory leaks removed
This commit is contained in:
parent
8242e9ed41
commit
1a1dc417c4
|
@ -399,7 +399,8 @@ cr_order(variant var, char * buffer, const void * userdata)
|
||||||
}
|
}
|
||||||
*wp++ = '\"';
|
*wp++ = '\"';
|
||||||
*wp++ = 0;
|
*wp++ = 0;
|
||||||
/* sprintf(buffer, "\"%s\"", cmd); */
|
|
||||||
|
free(cmd);
|
||||||
}
|
}
|
||||||
else strcpy(buffer, "\"\"");
|
else strcpy(buffer, "\"\"");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -73,12 +73,6 @@
|
||||||
# include <items/seed.h>
|
# include <items/seed.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct donation {
|
|
||||||
struct donation *next;
|
|
||||||
struct faction *f1, *f2;
|
|
||||||
int amount;
|
|
||||||
} donation;
|
|
||||||
|
|
||||||
typedef struct request {
|
typedef struct request {
|
||||||
struct request * next;
|
struct request * next;
|
||||||
struct unit *unit;
|
struct unit *unit;
|
||||||
|
@ -372,6 +366,11 @@ free_recruitments(recruitment * recruits)
|
||||||
while (recruits) {
|
while (recruits) {
|
||||||
recruitment * rec = recruits;
|
recruitment * rec = recruits;
|
||||||
recruits = rec->next;
|
recruits = rec->next;
|
||||||
|
while (rec->requests) {
|
||||||
|
request * req = rec->requests;
|
||||||
|
rec->requests = req->next;
|
||||||
|
free(req);
|
||||||
|
}
|
||||||
free(rec);
|
free(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,8 +844,8 @@ report_donations(void)
|
||||||
{
|
{
|
||||||
region * r;
|
region * r;
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
donation * sp;
|
while (r->donations) {
|
||||||
for (sp = r->donations; sp; sp = sp->next) {
|
donation * sp = r->donations;
|
||||||
if (sp->amount > 0) {
|
if (sp->amount > 0) {
|
||||||
struct message * msg = msg_message("donation",
|
struct message * msg = msg_message("donation",
|
||||||
"from to amount", sp->f1, sp->f2, sp->amount);
|
"from to amount", sp->f1, sp->f2, sp->amount);
|
||||||
|
@ -854,6 +853,8 @@ report_donations(void)
|
||||||
r_addmessage(r, sp->f2, msg);
|
r_addmessage(r, sp->f2, msg);
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
}
|
}
|
||||||
|
r->donations = sp->next;
|
||||||
|
free(sp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -979,4 +979,5 @@ plan_monsters(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pathfinder_cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -871,16 +871,20 @@ static void
|
||||||
rp_battles(FILE * F, faction * f)
|
rp_battles(FILE * F, faction * f)
|
||||||
{
|
{
|
||||||
if (f->battles!=NULL) {
|
if (f->battles!=NULL) {
|
||||||
struct bmsg * bm;
|
|
||||||
rnl(F);
|
rnl(F);
|
||||||
centre(F, LOC(f->locale, "section_battle"), false);
|
centre(F, LOC(f->locale, "section_battle"), false);
|
||||||
rnl(F);
|
rnl(F);
|
||||||
for (bm=f->battles;bm;bm=bm->next) {
|
|
||||||
|
while (f->battles) {
|
||||||
|
struct bmsg * bm = f->battles;
|
||||||
|
f->battles = bm->next;
|
||||||
RENDER(f, buf, 80, ("battle::header", "region", bm->r));
|
RENDER(f, buf, 80, ("battle::header", "region", bm->r));
|
||||||
rnl(F);
|
rnl(F);
|
||||||
centre(F, buf, true);
|
centre(F, buf, true);
|
||||||
rnl(F);
|
rnl(F);
|
||||||
rp_messages(F, bm->msgs, f, 0, true, false);
|
rp_messages(F, bm->msgs, f, 0, true, false);
|
||||||
|
free_messagelist(bm->msgs);
|
||||||
|
free(bm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1416,7 +1416,7 @@ select_opponent(battle * b, troop at, int minrow, int maxrow)
|
||||||
*
|
*
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* cv_kill(fgs); Nicht vergessen
|
* cv_kill(fgs); free(fgs); Nicht vergessen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cvector *
|
cvector *
|
||||||
|
|
|
@ -30,3 +30,29 @@ get_gamedate(int turn, gamedate * gd)
|
||||||
return gd;
|
return gd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
calendar_cleanup(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
free(agename);
|
||||||
|
|
||||||
|
for (i=0;i!=seasons;++i) {
|
||||||
|
free(seasonnames[i]);
|
||||||
|
}
|
||||||
|
free(seasonnames);
|
||||||
|
|
||||||
|
for (i=0;i!=months_per_year;++i) {
|
||||||
|
free(monthnames[i]);
|
||||||
|
}
|
||||||
|
free(storms);
|
||||||
|
free(month_season);
|
||||||
|
free(monthnames);
|
||||||
|
|
||||||
|
for (i=0;i!=weeks_per_month;++i) {
|
||||||
|
free(weeknames[i]);
|
||||||
|
free(weeknames2[i]);
|
||||||
|
}
|
||||||
|
free(weeknames);
|
||||||
|
free(weeknames2);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef KRNL_CALENDAR_H
|
#ifndef KRNL_CALENDAR_H
|
||||||
#define KRNL_CALENDAR_H
|
#define KRNL_CALENDAR_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char *agename;
|
extern char *agename;
|
||||||
extern int first_turn;
|
extern int first_turn;
|
||||||
extern int first_month;
|
extern int first_month;
|
||||||
|
@ -25,5 +29,9 @@ typedef struct gamedate {
|
||||||
} gamedate;
|
} gamedate;
|
||||||
|
|
||||||
extern gamedate * get_gamedate(int turn, gamedate * gd);
|
extern gamedate * get_gamedate(int turn, gamedate * gd);
|
||||||
|
extern void calendar_cleanup(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -355,6 +355,7 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
if (k == 0) {
|
if (k == 0) {
|
||||||
/* keine Waffen mehr da, die zerstört werden könnten */
|
/* keine Waffen mehr da, die zerstört werden könnten */
|
||||||
|
@ -678,6 +679,7 @@ sp_immolation(fighter * fi, int level, double power, spell * sp)
|
||||||
if (force==0) break;
|
if (force==0) break;
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
sprintf(buf, "%d Personen %s getötet",
|
sprintf(buf, "%d Personen %s getötet",
|
||||||
killed, killed == 1 ? "wurde" : "wurden");
|
killed, killed == 1 ? "wurde" : "wurden");
|
||||||
|
@ -968,6 +970,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
|
||||||
power = max(0, power-n);
|
power = max(0, power-n);
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
scat("Ein plötzlicher Tumult entsteht");
|
scat("Ein plötzlicher Tumult entsteht");
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
|
@ -1045,6 +1048,7 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
sprintf(buf, "%d Krieger %s von Furcht gepackt.", panik,
|
sprintf(buf, "%d Krieger %s von Furcht gepackt.", panik,
|
||||||
panik == 1 ? "wurde" : "wurden");
|
panik == 1 ? "wurde" : "wurden");
|
||||||
|
@ -1672,6 +1676,7 @@ sp_healing(fighter * fi, int level, double power, spell * sp)
|
||||||
j += heal_fighters(fgs, &healhp, false);
|
j += heal_fighters(fgs, &healhp, false);
|
||||||
j += heal_fighters(fgs, &healhp, true);
|
j += heal_fighters(fgs, &healhp, true);
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
scat(", doch niemand mußte magisch geheilt werden.");
|
scat(", doch niemand mußte magisch geheilt werden.");
|
||||||
|
@ -1754,6 +1759,7 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
free(fgs);
|
||||||
|
|
||||||
if (undead == 0) {
|
if (undead == 0) {
|
||||||
sprintf(buf, "%s kann keine Untoten rufen.", unitname(mage));
|
sprintf(buf, "%s kann keine Untoten rufen.", unitname(mage));
|
||||||
|
|
|
@ -3032,7 +3032,7 @@ void
|
||||||
add_income(unit * u, int type, int want, int qty)
|
add_income(unit * u, int type, int want, int qty)
|
||||||
{
|
{
|
||||||
if (want==INT_MAX) want = qty;
|
if (want==INT_MAX) want = qty;
|
||||||
add_message(&u->faction->msgs, new_message(u->faction, "income%u:unit%r:region%i:mode%i:wanted%i:amount",
|
ADDMSG(&u->faction->msgs, msg_message("income", "unit region mode wanted amount",
|
||||||
u, u->region, type, want, qty));
|
u, u->region, type, want, qty));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ cmistake(const unit * u, struct order *ord, int mno, int mtype)
|
||||||
if (u->faction->no == MONSTER_FACTION) return;
|
if (u->faction->no == MONSTER_FACTION) return;
|
||||||
sprintf(ebuf, "error%d", mno);
|
sprintf(ebuf, "error%d", mno);
|
||||||
ADDMSG(&u->faction->msgs, msg_message(ebuf,
|
ADDMSG(&u->faction->msgs, msg_message(ebuf,
|
||||||
"command unit region", copy_order(ord), u, u->region));
|
"command unit region", ord, u, u->region));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern unsigned int new_hashstring(const char* s);
|
extern unsigned int new_hashstring(const char* s);
|
||||||
|
|
|
@ -1786,6 +1786,7 @@ run_to(unit * u, region * to)
|
||||||
region_list * route = NULL;
|
region_list * route = NULL;
|
||||||
add_regionlist(&route, to);
|
add_regionlist(&route, to);
|
||||||
travel_route(u, route, NULL, NULL, TRAVEL_RUNNING);
|
travel_route(u, route, NULL, NULL, TRAVEL_RUNNING);
|
||||||
|
free_regionlist(route);
|
||||||
/* weder transport noch follow */
|
/* weder transport noch follow */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,16 @@ typedef struct node {
|
||||||
|
|
||||||
static node * node_garbage;
|
static node * node_garbage;
|
||||||
|
|
||||||
|
void
|
||||||
|
pathfinder_cleanup(void)
|
||||||
|
{
|
||||||
|
while (node_garbage) {
|
||||||
|
node * n = node_garbage;
|
||||||
|
node_garbage = n->next;
|
||||||
|
free(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static node *
|
static node *
|
||||||
new_node(region * r, int distance, node * prev)
|
new_node(region * r, int distance, node * prev)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,9 @@ extern boolean allowed_swim(const struct region * src, const struct region * tar
|
||||||
extern boolean allowed_fly(const struct region * src, const struct region * target);
|
extern boolean allowed_fly(const struct region * src, const struct region * target);
|
||||||
extern boolean allowed_walk(const struct region * src, const struct region * target);
|
extern boolean allowed_walk(const struct region * src, const struct region * target);
|
||||||
extern struct region_list * regions_in_range(struct region * src, int maxdist, boolean (*allowed)(const struct region*, const struct region*));
|
extern struct region_list * regions_in_range(struct region * src, int maxdist, boolean (*allowed)(const struct region*, const struct region*));
|
||||||
|
|
||||||
|
extern void pathfinder_cleanup(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -821,6 +821,13 @@ free_region(region * r)
|
||||||
r->resources = res->next;
|
r->resources = res->next;
|
||||||
free(res);
|
free(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (r->donations) {
|
||||||
|
donation * don = r->donations;
|
||||||
|
r->donations = don->next;
|
||||||
|
free(don);
|
||||||
|
}
|
||||||
|
|
||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,12 @@ typedef struct land_region {
|
||||||
#endif
|
#endif
|
||||||
} land_region;
|
} land_region;
|
||||||
|
|
||||||
|
typedef struct donation {
|
||||||
|
struct donation *next;
|
||||||
|
struct faction *f1, *f2;
|
||||||
|
int amount;
|
||||||
|
} donation;
|
||||||
|
|
||||||
typedef struct region {
|
typedef struct region {
|
||||||
struct region *next;
|
struct region *next;
|
||||||
struct land_region *land;
|
struct land_region *land;
|
||||||
|
|
|
@ -1122,6 +1122,11 @@ stripunit(unit * u)
|
||||||
u->items = it;
|
u->items = it;
|
||||||
}
|
}
|
||||||
while (u->attribs) a_remove (&u->attribs, u->attribs);
|
while (u->attribs) a_remove (&u->attribs, u->attribs);
|
||||||
|
while (u->reservations) {
|
||||||
|
struct reservation *res = u->reservations;
|
||||||
|
u->reservations = res->next;
|
||||||
|
free(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/border.h>
|
#include <kernel/border.h>
|
||||||
#include <kernel/building.h>
|
#include <kernel/building.h>
|
||||||
|
#include <kernel/calendar.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
#include <kernel/message.h>
|
#include <kernel/message.h>
|
||||||
|
@ -431,6 +432,7 @@ game_done(void)
|
||||||
|
|
||||||
creport_cleanup();
|
creport_cleanup();
|
||||||
report_cleanup();
|
report_cleanup();
|
||||||
|
calendar_cleanup();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue