NULL-ize some variables to make unit tests happy.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2016-11-12 18:58:05 +03:00
parent 9a39e35dc3
commit 2356acc26d
5 changed files with 22 additions and 5 deletions

View File

@ -225,6 +225,8 @@ free_codepages_list (void)
{
g_ptr_array_foreach (codepages, free_codepage_desc, NULL);
g_ptr_array_free (codepages, TRUE);
/* NULL-ize pointer to make unit tests happy */
codepages = NULL;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -31,6 +31,7 @@
#include <errno.h>
#include "lib/global.h"
#include "lib/util.h" /* MC_PTR_FREE */
#include "lib/strutil.h"
/*** global variables ****************************************************************************/
@ -425,8 +426,9 @@ str_uninit_strings (void)
{
if (str_cnv_not_convert != INVALID_CONV)
g_iconv_close (str_cnv_not_convert);
g_free (term_encoding);
g_free (codeset);
/* NULL-ize pointers to avoid double free in unit tests */
MC_PTR_FREE (term_encoding);
MC_PTR_FREE (codeset);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -93,7 +93,7 @@ struct vfs_openfile
/** They keep track of the current directory */
static vfs_path_t *current_path = NULL;
static GPtrArray *vfs_openfiles;
static GPtrArray *vfs_openfiles = NULL;
static long vfs_free_handle_list = -1;
/* --------------------------------------------------------------------------------------------- */
@ -493,10 +493,16 @@ vfs_shut (void)
vfs->done (vfs);
}
/* NULL-ize pointers to make unit tests happy */
g_ptr_array_free (vfs_openfiles, TRUE);
vfs_openfiles = NULL;
g_ptr_array_free (vfs__classes_list, TRUE);
vfs__classes_list = NULL;
g_string_free (vfs_str_buffer, TRUE);
g_free (mc_readdir_result);
vfs_str_buffer = NULL;
current_vfs = NULL;
vfs_free_handle_list = -1;
MC_PTR_FREE (mc_readdir_result);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -105,12 +105,15 @@ sigaction__deinit (void)
{
g_ptr_array_foreach (sigaction_signum__captured, (GFunc) g_free, NULL);
g_ptr_array_free (sigaction_signum__captured, TRUE);
sigaction_signum__captured = NULL;
g_ptr_array_foreach (sigaction_act__captured, (GFunc) g_free, NULL);
g_ptr_array_free (sigaction_act__captured, TRUE);
sigaction_act__captured = NULL;
g_ptr_array_foreach (sigaction_oldact__captured, (GFunc) g_free, NULL);
g_ptr_array_free (sigaction_oldact__captured, TRUE);
sigaction_oldact__captured = NULL;
}
/* --------------------------------------------------------------------------------------------- */
@ -159,9 +162,11 @@ signal__deinit (void)
{
g_ptr_array_foreach (signal_signum__captured, (GFunc) g_free, NULL);
g_ptr_array_free (signal_signum__captured, TRUE);
signal_signum__captured = NULL;
g_ptr_array_foreach (signal_handler__captured, (GFunc) g_free, NULL);
g_ptr_array_free (signal_handler__captured, TRUE);
signal_handler__captured = NULL;
}
/* --------------------------------------------------------------------------------------------- */
@ -220,7 +225,8 @@ execvp__deinit (void)
{
g_ptr_array_foreach (execvp__args__captured, (GFunc) g_free, NULL);
g_ptr_array_free (execvp__args__captured, TRUE);
g_free (execvp__file__captured);
execvp__args__captured = NULL;
MC_PTR_FREE (execvp__file__captured);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -194,6 +194,7 @@ mc_stat__deinit (void)
{
g_ptr_array_foreach (mc_stat__vpath__captured, (GFunc) vfs_path_free, NULL);
g_ptr_array_free (mc_stat__vpath__captured, TRUE);
mc_stat__vpath__captured = NULL;
}
/* --------------------------------------------------------------------------------------------- */