From f85524cf0fe5fd7e6fbbc5a16c90ad4eb47f8978 Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Tue, 30 Dec 2003 22:41:47 +0000 Subject: [PATCH] some more memory management stuff git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@5 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index e7c9654..4594f11 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -97,7 +97,7 @@ char ttyrec_filename[100]; /* makes a max number of users compiled in */ int f_num = 0; struct dg_user** users = NULL; -struct dg_user* me; +struct dg_user* me = NULL; /* ************************************************************* */ /* for ttyrec */ @@ -534,8 +534,12 @@ freefile () free (users[i]->username); free (users[i]->email); free (users[i]->env); + free (users[i]); } + free(users); + users = NULL; + me = NULL; f_num = 0; } @@ -554,14 +558,6 @@ initncurses () /* ************************************************************* */ -void -initvars () -{ - me = malloc(sizeof(struct dg_user)); -} - -/* ************************************************************* */ - void login () { @@ -633,6 +629,11 @@ newuser () loggedin = 0; + if (me) + free(me); + + me = malloc(sizeof(struct dg_user)); + while (error) { clear (); @@ -1019,8 +1020,6 @@ main (void) setgid (newgid); setuid (newuid); - initvars (); - /* simple login routine, uses ncurses */ if (readfile (0)) exit (110);