Commit f94c3b49 authored by Darin Adler's avatar Darin Adler
Browse files

Leak-checking-related fixes.

	* libnautilus-extensions/nautilus-file.c: (destroy):
	Fixed a storage leak (we weren't freeing file->details).
	* libnautilus-extensions/nautilus-self-checks.c:
	(nautilus_check_string_result): Fixed a storage leak.

	* libnautilus-extensions/nautilus-directory-async.c:
	(metafile_read_done), (metafile_read_failed),
	(metafile_read_complete): Added some asserts.
	* libnautilus-extensions/nautilus-directory.c:
	(nautilus_self_check_directory): Added one more "assert".

	* libnautilus-extensions/nautilus-lib-self-check-functions.c:
	(nautilus_run_lib_self_checks): Formatting tweaks.
	* nautilus-widgets/nautilus-widgets-self-check-functions.c:
	(nautilus_widgets_run_self_checks): Formatting tweaks.

	* nautilus-widgets/nautilus-preference.c:
	(nautilus_widgets_self_check_preference): Made the test
	not repeat things so many times. It doesn't help find the
	leaks, it actually hurts :-)

	* src/nautilus-application.c: (nautilus_app_quit):
	* src/nautilus-main.c: (main):
	Moved the gnome_vfs_shutdown out to the main loop instead of
	putting it inside nautilus-application.c since that matches
	how we do the initializing.
parent 4a0b4787
2000-06-07 Darin Adler <darin@eazel.com>
Leak-checking-related fixes.
* libnautilus-extensions/nautilus-file.c: (destroy):
Fixed a storage leak (we weren't freeing file->details).
* libnautilus-extensions/nautilus-self-checks.c:
(nautilus_check_string_result): Fixed a storage leak.
* libnautilus-extensions/nautilus-directory-async.c:
(metafile_read_done), (metafile_read_failed),
(metafile_read_complete): Added some asserts.
* libnautilus-extensions/nautilus-directory.c:
(nautilus_self_check_directory): Added one more "assert".
* libnautilus-extensions/nautilus-lib-self-check-functions.c:
(nautilus_run_lib_self_checks): Formatting tweaks.
* nautilus-widgets/nautilus-widgets-self-check-functions.c:
(nautilus_widgets_run_self_checks): Formatting tweaks.
* nautilus-widgets/nautilus-preference.c:
(nautilus_widgets_self_check_preference): Made the test
not repeat things so many times. It doesn't help find the
leaks, it actually hurts :-)
* src/nautilus-application.c: (nautilus_app_quit):
* src/nautilus-main.c: (main):
Moved the gnome_vfs_shutdown out to the main loop instead of
putting it inside nautilus-application.c since that matches
how we do the initializing.
2000-06-07 Andy Hertzfeld <andy@eazel.com>
* src/nautilus-location-bar.c: (accumulate_name),
......
......@@ -179,6 +179,9 @@ nautilus_metafile_read_cancel (NautilusDirectory *directory)
static void
metafile_read_done (NautilusDirectory *directory)
{
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
g_free (directory->details->metafile_read_state);
directory->details->metafile_read = TRUE;
......@@ -196,6 +199,8 @@ metafile_read_failed (NautilusDirectory *directory)
{
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (directory->details->metafile == NULL);
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
g_free (directory->details->metafile_read_state->buffer);
......@@ -219,6 +224,8 @@ metafile_read_complete (NautilusDirectory *directory)
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (directory->details->metafile == NULL);
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
/* The gnome-xml parser requires a zero-terminated array. */
size = directory->details->metafile_read_state->bytes_read;
......
......@@ -394,11 +394,11 @@ nautilus_directory_new (const char* uri)
directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
directory->details->uri_text = g_strdup(uri);
directory->details->uri_text = g_strdup (uri);
directory->details->uri = vfs_uri;
directory->details->metafile_uri = metafile_uri;
directory->details->alternate_metafile_uri = alternate_metafile_uri;
directory->details->is_local = gnome_vfs_uri_is_local(vfs_uri);
directory->details->is_local = gnome_vfs_uri_is_local (vfs_uri);
return directory;
}
......@@ -1077,6 +1077,8 @@ nautilus_self_check_directory (void)
nautilus_directory_unref (directory);
NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directory_objects), 0);
/* escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_escape_slashes ("a"), "a");
......
......@@ -229,6 +229,8 @@ destroy (GtkObject *object)
}
nautilus_directory_unref (file->details->directory);
g_free (file->details);
}
NautilusFile *
......
......@@ -29,7 +29,8 @@
#include "nautilus-lib-self-check-functions.h"
void nautilus_run_lib_self_checks ()
void
nautilus_run_lib_self_checks (void)
{
NAUTILUS_LIB_FOR_EACH_SELF_CHECK_FUNCTION (NAUTILUS_CALL_SELF_CHECK_FUNCTION)
}
......
......@@ -853,7 +853,7 @@ nautilus_widgets_self_check_preference (void)
/* Allocate a bunch of preference objects to test that they dont leak */
{
const guint num_to_allocate = 666;
const guint num_to_allocate = 20; /* larger number is too slow with memprof */
guint i;
for (i = 0; i < num_to_allocate; i++)
......
......@@ -89,7 +89,7 @@ nautilus_before_check (const char *expression,
}
static void
nautilus_after_check ()
nautilus_after_check (void)
{
/* It would be good to check here if there was a memory leak. */
}
......@@ -98,8 +98,8 @@ void
nautilus_check_boolean_result (gboolean result, gboolean expected)
{
if (result != expected) {
nautilus_report_check_failure (nautilus_strdup_boolean(result),
nautilus_strdup_boolean(expected));
nautilus_report_check_failure (nautilus_strdup_boolean (result),
nautilus_strdup_boolean (expected));
}
nautilus_after_check ();
}
......@@ -108,8 +108,8 @@ void
nautilus_check_integer_result (long result, long expected)
{
if (result != expected) {
nautilus_report_check_failure (g_strdup_printf("%ld", result),
g_strdup_printf("%ld", expected));
nautilus_report_check_failure (g_strdup_printf ("%ld", result),
g_strdup_printf ("%ld", expected));
}
nautilus_after_check ();
}
......@@ -130,6 +130,8 @@ nautilus_check_string_result (char *result, const char *expected)
if (!match) {
nautilus_report_check_failure (result, g_strdup (expected));
} else {
g_free (result);
}
nautilus_after_check ();
}
......
......@@ -29,7 +29,8 @@
#include "nautilus-widgets-self-check-functions.h"
void nautilus_widgets_run_self_checks ()
void
nautilus_widgets_run_self_checks (void)
{
NAUTILUS_WIDGETS_FOR_EACH_SELF_CHECK_FUNCTION (NAUTILUS_CALL_SELF_CHECK_FUNCTION)
}
......
......@@ -179,6 +179,9 @@ nautilus_metafile_read_cancel (NautilusDirectory *directory)
static void
metafile_read_done (NautilusDirectory *directory)
{
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
g_free (directory->details->metafile_read_state);
directory->details->metafile_read = TRUE;
......@@ -196,6 +199,8 @@ metafile_read_failed (NautilusDirectory *directory)
{
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (directory->details->metafile == NULL);
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
g_free (directory->details->metafile_read_state->buffer);
......@@ -219,6 +224,8 @@ metafile_read_complete (NautilusDirectory *directory)
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (directory->details->metafile == NULL);
g_assert (directory->details->metafile_read_state != NULL);
g_assert (directory->details->metafile_read_state->is_open == FALSE);
/* The gnome-xml parser requires a zero-terminated array. */
size = directory->details->metafile_read_state->bytes_read;
......
......@@ -394,11 +394,11 @@ nautilus_directory_new (const char* uri)
directory = gtk_type_new (NAUTILUS_TYPE_DIRECTORY);
directory->details->uri_text = g_strdup(uri);
directory->details->uri_text = g_strdup (uri);
directory->details->uri = vfs_uri;
directory->details->metafile_uri = metafile_uri;
directory->details->alternate_metafile_uri = alternate_metafile_uri;
directory->details->is_local = gnome_vfs_uri_is_local(vfs_uri);
directory->details->is_local = gnome_vfs_uri_is_local (vfs_uri);
return directory;
}
......@@ -1077,6 +1077,8 @@ nautilus_self_check_directory (void)
nautilus_directory_unref (directory);
NAUTILUS_CHECK_INTEGER_RESULT (g_hash_table_size (directory_objects), 0);
/* escape_slashes */
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_escape_slashes (""), "");
NAUTILUS_CHECK_STRING_RESULT (nautilus_str_escape_slashes ("a"), "a");
......
......@@ -229,6 +229,8 @@ destroy (GtkObject *object)
}
nautilus_directory_unref (file->details->directory);
g_free (file->details);
}
NautilusFile *
......
......@@ -29,7 +29,8 @@
#include "nautilus-lib-self-check-functions.h"
void nautilus_run_lib_self_checks ()
void
nautilus_run_lib_self_checks (void)
{
NAUTILUS_LIB_FOR_EACH_SELF_CHECK_FUNCTION (NAUTILUS_CALL_SELF_CHECK_FUNCTION)
}
......
......@@ -853,7 +853,7 @@ nautilus_widgets_self_check_preference (void)
/* Allocate a bunch of preference objects to test that they dont leak */
{
const guint num_to_allocate = 666;
const guint num_to_allocate = 20; /* larger number is too slow with memprof */
guint i;
for (i = 0; i < num_to_allocate; i++)
......
......@@ -89,7 +89,7 @@ nautilus_before_check (const char *expression,
}
static void
nautilus_after_check ()
nautilus_after_check (void)
{
/* It would be good to check here if there was a memory leak. */
}
......@@ -98,8 +98,8 @@ void
nautilus_check_boolean_result (gboolean result, gboolean expected)
{
if (result != expected) {
nautilus_report_check_failure (nautilus_strdup_boolean(result),
nautilus_strdup_boolean(expected));
nautilus_report_check_failure (nautilus_strdup_boolean (result),
nautilus_strdup_boolean (expected));
}
nautilus_after_check ();
}
......@@ -108,8 +108,8 @@ void
nautilus_check_integer_result (long result, long expected)
{
if (result != expected) {
nautilus_report_check_failure (g_strdup_printf("%ld", result),
g_strdup_printf("%ld", expected));
nautilus_report_check_failure (g_strdup_printf ("%ld", result),
g_strdup_printf ("%ld", expected));
}
nautilus_after_check ();
}
......@@ -130,6 +130,8 @@ nautilus_check_string_result (char *result, const char *expected)
if (!match) {
nautilus_report_check_failure (result, g_strdup (expected));
} else {
g_free (result);
}
nautilus_after_check ();
}
......
......@@ -29,7 +29,8 @@
#include "nautilus-widgets-self-check-functions.h"
void nautilus_widgets_run_self_checks ()
void
nautilus_widgets_run_self_checks (void)
{
NAUTILUS_WIDGETS_FOR_EACH_SELF_CHECK_FUNCTION (NAUTILUS_CALL_SELF_CHECK_FUNCTION)
}
......
......@@ -853,7 +853,7 @@ nautilus_widgets_self_check_preference (void)
/* Allocate a bunch of preference objects to test that they dont leak */
{
const guint num_to_allocate = 666;
const guint num_to_allocate = 20; /* larger number is too slow with memprof */
guint i;
for (i = 0; i < num_to_allocate; i++)
......
......@@ -29,7 +29,8 @@
#include "nautilus-widgets-self-check-functions.h"
void nautilus_widgets_run_self_checks ()
void
nautilus_widgets_run_self_checks (void)
{
NAUTILUS_WIDGETS_FOR_EACH_SELF_CHECK_FUNCTION (NAUTILUS_CALL_SELF_CHECK_FUNCTION)
}
......
......@@ -441,7 +441,6 @@ nautilus_app_destroy_window (GtkObject *obj, NautilusApp *app)
void
nautilus_app_quit (void)
{
gnome_vfs_shutdown ();
gtk_main_quit ();
}
......
......@@ -105,5 +105,7 @@ main(int argc, char *argv[])
bonobo_object_unref (BONOBO_OBJECT (application));
}
gnome_vfs_shutdown ();
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment