From: John Darrington Date: Tue, 14 Nov 2006 11:47:17 +0000 (+0000) Subject: Plugged some small memory leaks X-Git-Tag: v0.6.0~696 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f7f751a47c68946a0fcbc9898f43f5499c5c6c5;p=pspp-builds.git Plugged some small memory leaks --- diff --git a/src/data/file-name.c b/src/data/file-name.c index 3216ef09..97d75e48 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -146,7 +146,7 @@ fn_tilde_expand (const char *input) pwd = getpwnam (ds_cstr (&user_name)); if (pwd != NULL && pwd->pw_dir[0] != '\0') { - home = pwd->pw_dir; + home = xstrdup (pwd->pw_dir); remainder = input + 1 + ds_length (&user_name); } ds_destroy (&user_name); diff --git a/src/data/format.c b/src/data/format.c index 06042d0e..e236aa31 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -60,10 +60,15 @@ fmt_init (void) } } +static struct fmt_number_style *styles[FMT_NUMBER_OF_FORMATS]; + /* Deinitialize the format module. */ void fmt_done (void) { + int t; + for (t = 0 ; t < FMT_NUMBER_OF_FORMATS ; ++t ) + fmt_number_style_destroy (styles[t]); } /* Returns an input format specification with type TYPE, width W, @@ -745,7 +750,6 @@ max_digits_for_bytes (int bytes) return map[bytes - 1]; } -static struct fmt_number_style *styles[FMT_NUMBER_OF_FORMATS]; /* Creates and returns a new struct fmt_number_style, initializing all affixes to empty strings. */ diff --git a/src/libpspp/pool.c b/src/libpspp/pool.c index 213efb9c..31a57e9f 100644 --- a/src/libpspp/pool.c +++ b/src/libpspp/pool.c @@ -700,8 +700,8 @@ pool_fopen (struct pool *pool, const char *file_name, const char *mode) assert (pool && file_name && mode); f = fopen (file_name, mode); - if (f == NULL) - return NULL; + if (f != NULL) + pool_attach_file (pool, f); return f; } diff --git a/src/ui/flexifile.c b/src/ui/flexifile.c index 9ed760b2..5d06f876 100644 --- a/src/ui/flexifile.c +++ b/src/ui/flexifile.c @@ -25,6 +25,7 @@ #include #include #include +#include struct class_flexifile diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 0613476b..a99f580d 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -194,6 +194,7 @@ terminate (bool success) outp_done (); msg_ui_done (); + fmt_done (); } exit (success ? EXIT_SUCCESS : EXIT_FAILURE); } diff --git a/src/ui/terminal/read-line.c b/src/ui/terminal/read-line.c index 08f93623..46b53b70 100644 --- a/src/ui/terminal/read-line.c +++ b/src/ui/terminal/read-line.c @@ -83,6 +83,8 @@ readln_uninitialize (void) #if HAVE_READLINE && unix if (history_file != NULL) write_history (history_file); + clear_history (); + free (history_file); #endif } @@ -157,7 +159,7 @@ readln_read (struct string *line, enum getl_prompt_style style) #endif } -#ifdef HAVE_READLINE +#if HAVE_READLINE static char *command_generator (const char *text, int state); /* Returns a set of command name completions for TEXT.