mirror of
https://github.com/paxed/dgamelaunch.git
synced 2025-07-26 23:24:38 +02:00
Free populated games.
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@476 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
parent
fff23611d8
commit
c08ce22995
@ -375,7 +375,7 @@ inprogressmenu (int gameid)
|
|||||||
int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
|
int i, menuchoice, len = 20, offset = 0, doresizewin = 0;
|
||||||
static dg_sortmode sortmode = NUM_SORTMODES;
|
static dg_sortmode sortmode = NUM_SORTMODES;
|
||||||
time_t ctime;
|
time_t ctime;
|
||||||
struct dg_game **games;
|
struct dg_game **games = NULL;
|
||||||
char ttyrecname[130], *replacestr = NULL, gametype[10];
|
char ttyrecname[130], *replacestr = NULL, gametype[10];
|
||||||
int *is_nhext;
|
int *is_nhext;
|
||||||
sigset_t oldmask, toblock;
|
sigset_t oldmask, toblock;
|
||||||
@ -405,7 +405,7 @@ inprogressmenu (int gameid)
|
|||||||
max_height = local_LINES - 10;
|
max_height = local_LINES - 10;
|
||||||
if (max_height < 2) {
|
if (max_height < 2) {
|
||||||
free(is_nhext);
|
free(is_nhext);
|
||||||
/* TODO: free games[] */
|
free_populated_games(games, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (max_height > abs_max_height) max_height = abs_max_height;
|
if (max_height > abs_max_height) max_height = abs_max_height;
|
||||||
@ -507,6 +507,7 @@ inprogressmenu (int gameid)
|
|||||||
case ERR:
|
case ERR:
|
||||||
case 'q': case 'Q':
|
case 'q': case 'Q':
|
||||||
if (is_nhext) free(is_nhext);
|
if (is_nhext) free(is_nhext);
|
||||||
|
free_populated_games(games, len);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case '.':
|
case '.':
|
||||||
@ -597,6 +598,7 @@ watchgame:
|
|||||||
games = sort_games (games, len, sortmode);
|
games = sort_games (games, len, sortmode);
|
||||||
}
|
}
|
||||||
if (is_nhext) free(is_nhext);
|
if (is_nhext) free(is_nhext);
|
||||||
|
free_populated_games(games, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************* */
|
/* ************************************************************* */
|
||||||
@ -769,7 +771,7 @@ void
|
|||||||
wall_email(char *from, char *msg)
|
wall_email(char *from, char *msg)
|
||||||
{
|
{
|
||||||
int len, i;
|
int len, i;
|
||||||
struct dg_game **games;
|
struct dg_game **games = NULL;
|
||||||
char spool_fn[1024+1];
|
char spool_fn[1024+1];
|
||||||
FILE *user_spool = NULL;
|
FILE *user_spool = NULL;
|
||||||
struct flock fl = { 0 };
|
struct flock fl = { 0 };
|
||||||
@ -817,6 +819,7 @@ wall_email(char *from, char *msg)
|
|||||||
fprintf(user_spool, "%s:%s\n", from, msg);
|
fprintf(user_spool, "%s:%s\n", from, msg);
|
||||||
fclose(user_spool);
|
fclose(user_spool);
|
||||||
}
|
}
|
||||||
|
free_populated_games(games, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1874,7 +1877,7 @@ authenticate ()
|
|||||||
{
|
{
|
||||||
int i, len, me_index;
|
int i, len, me_index;
|
||||||
char user_buf[22], pw_buf[22];
|
char user_buf[22], pw_buf[22];
|
||||||
struct dg_game **games;
|
struct dg_game **games = NULL;
|
||||||
|
|
||||||
/* We use simple password authentication, rather than challenge/response. */
|
/* We use simple password authentication, rather than challenge/response. */
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
@ -1911,10 +1914,12 @@ authenticate ()
|
|||||||
if (!strcmp (games[i]->name, user_buf))
|
if (!strcmp (games[i]->name, user_buf))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Game already in progress.\n");
|
fprintf (stderr, "Game already in progress.\n");
|
||||||
|
free_populated_games(games, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
win.ws_row = win.ws_col = 0;
|
win.ws_row = win.ws_col = 0;
|
||||||
gen_inprogress_lock (0, getppid (), gen_nhext_filename ());
|
gen_inprogress_lock (0, getppid (), gen_nhext_filename ());
|
||||||
|
free_populated_games(games, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1922,6 +1927,7 @@ authenticate ()
|
|||||||
|
|
||||||
sleep (2);
|
sleep (2);
|
||||||
fprintf (stderr, "Login failed.\n");
|
fprintf (stderr, "Login failed.\n");
|
||||||
|
free_populated_games(games, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ extern struct dg_menu *dgl_find_menu(char *menuname);
|
|||||||
|
|
||||||
extern int dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me);
|
extern int dgl_exec_cmdqueue(struct dg_cmdpart *queue, int game, struct dg_user *me);
|
||||||
|
|
||||||
|
extern void free_populated_games(struct dg_game **games, int len);
|
||||||
extern struct dg_game **populate_games(int game, int *l, struct dg_user *me);
|
extern struct dg_game **populate_games(int game, int *l, struct dg_user *me);
|
||||||
|
|
||||||
#ifdef USE_DEBUGFILE
|
#ifdef USE_DEBUGFILE
|
||||||
|
16
dgl-common.c
16
dgl-common.c
@ -403,6 +403,22 @@ debug_write(char *str)
|
|||||||
}
|
}
|
||||||
#endif /* USE_DEBUGFILE */
|
#endif /* USE_DEBUGFILE */
|
||||||
|
|
||||||
|
void
|
||||||
|
free_populated_games(struct dg_game **games, int len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (!games || (len < 1)) return;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
if (games[i]->ttyrec_fn) free(games[i]->ttyrec_fn);
|
||||||
|
if (games[i]->name) free(games[i]->name);
|
||||||
|
if (games[i]->date) free(games[i]->date);
|
||||||
|
if (games[i]->time) free(games[i]->time);
|
||||||
|
free(games[i]);
|
||||||
|
}
|
||||||
|
free(games);
|
||||||
|
}
|
||||||
|
|
||||||
struct dg_game **
|
struct dg_game **
|
||||||
populate_games (int xgame, int *l, struct dg_user *me)
|
populate_games (int xgame, int *l, struct dg_user *me)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user