From 33ffe9aadcef483a4900cc65fc9e840220951e3c Mon Sep 17 00:00:00 2001 From: bertrand Date: Wed, 11 Aug 1999 10:59:17 +0000 Subject: Message creation still consumes a lot of memory (maybe 2000k) and I really don't understand why. As soon as I get gtk working on SunOS, purify should hopefully give me the answer. 1999-08-11 bertrand * camel/camel-service.c (_finalize): * camel/camel-stream-fs.c (_finalize): (_destroy): close file descriptor. * camel/camel-stream-mem.c (_finalize): * camel/camel-store.c (_finalize): * camel/camel-folder.c (_finalize): svn path=/trunk/; revision=1104 --- camel/camel-folder.c | 20 +++++++++++++++++++- camel/camel-mime-body-part.c | 2 ++ camel/camel-mime-message.c | 3 ++- camel/camel-service.c | 17 +++++++++++++++++ camel/camel-store.c | 22 ++++++++++++++++++++++ camel/camel-stream-fs.c | 40 ++++++++++++++++++++++++++++++++++++++++ camel/camel-stream-mem.c | 19 +++++++++++++++++++ 7 files changed, 121 insertions(+), 2 deletions(-) (limited to 'camel') diff --git a/camel/camel-folder.c b/camel/camel-folder.c index 2d0a29faab..1ea2a7247b 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -22,6 +22,7 @@ */ #include #include "camel-folder.h" +#include "camel-log.h" #include "string-utils.h" static GtkObjectClass *parent_class=NULL; @@ -53,10 +54,13 @@ static CamelMimeMessage *_get_message (CamelFolder *folder, gint number); static gint _get_message_count (CamelFolder *folder); static gint _append_message (CamelFolder *folder, CamelMimeMessage *message); +static void _finalize (GtkObject *object); static void camel_folder_class_init (CamelFolderClass *camel_folder_class) { + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_folder_class); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ @@ -83,6 +87,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->append_message = _append_message; /* virtual method overload */ + gtk_object_class->finalize = _finalize; } @@ -116,6 +121,18 @@ camel_folder_get_type (void) } +static void +_finalize (GtkObject *object) +{ + CamelFolder *camel_folder = CAMEL_FOLDER (object); + CAMEL_LOG_FULL_DEBUG ("Entering CamelFolder::finalize\n"); + + if (camel_folder->name) g_free (camel_folder->name); + if (camel_folder->full_name) g_free (camel_folder->full_name); + + GTK_OBJECT_CLASS (parent_class)->finalize (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelFolder::finalize\n"); +} /** @@ -131,7 +148,9 @@ _init_with_store (CamelFolder *folder, CamelStore *parent_store) g_assert(folder); g_assert(parent_store); + if (folder->parent_store) gtk_object_unref (GTK_OBJECT (folder->parent_store)); folder->parent_store = parent_store; + if (parent_store) gtk_object_ref (GTK_OBJECT (parent_store)); } @@ -455,7 +474,6 @@ _create(CamelFolder *folder) } else { parent = camel_store_get_folder (folder->parent_store, prefix); camel_folder_create (parent); - gtk_object_unref (GTK_OBJECT (parent)); } } } diff --git a/camel/camel-mime-body-part.c b/camel/camel-mime-body-part.c index 3b0c547bfa..570c2fe6d4 100644 --- a/camel/camel-mime-body-part.c +++ b/camel/camel-mime-body-part.c @@ -96,7 +96,9 @@ camel_mime_body_part_new () static void _set_parent (CamelMimeBodyPart *mime_body_part, CamelMultipart *multipart) { + if (mime_body_part->parent) gtk_object_unref (GTK_OBJECT (mime_body_part->parent)); mime_body_part->parent = multipart; + if (multipart) gtk_object_ref (GTK_OBJECT (multipart)); } diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 1563c0cb1d..acff82ca71 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -99,7 +99,7 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) { CamelDataWrapperClass *camel_data_wrapper_class = CAMEL_DATA_WRAPPER_CLASS (camel_mime_message_class); CamelMimePartClass *camel_mime_part_class = CAMEL_MIME_PART_CLASS (camel_mime_message_class); - GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_data_wrapper_class); + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_mime_message_class); parent_class = gtk_type_class (camel_mime_part_get_type ()); _init_header_name_table(); @@ -656,5 +656,6 @@ _parse_header_pair (CamelMimePart *mime_part, gchar *header_name, gchar *header_ return TRUE; } else return parent_class->parse_header_pair (mime_part, header_name, header_value); + } diff --git a/camel/camel-service.c b/camel/camel-service.c index 0a27eb78fe..cdbb679dd0 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -22,6 +22,7 @@ */ #include #include "camel-service.h" +#include "camel-log.h" static GtkObjectClass *parent_class=NULL; @@ -34,10 +35,13 @@ static void _connect_to_with_login_passwd_port (CamelService *service, gchar *ho static gboolean _is_connected (CamelService *service); static void _set_connected (CamelService *service, gboolean state); static const gchar *_get_url (CamelService *service); +static void _finalize (GtkObject *object); static void camel_service_class_init (CamelServiceClass *camel_service_class) { + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_service_class); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ @@ -49,6 +53,7 @@ camel_service_class_init (CamelServiceClass *camel_service_class) camel_service_class->get_url = _get_url; /* virtual method overload */ + gtk_object_class->finalize = _finalize; } @@ -82,6 +87,18 @@ camel_service_get_type (void) } +static void +_finalize (GtkObject *object) +{ + CamelService *camel_service = CAMEL_SERVICE (object); + + CAMEL_LOG_FULL_DEBUG ("Entering CamelService::finalize\n"); + + if (camel_service->url) g_free (camel_service->url); + + GTK_OBJECT_CLASS (parent_class)->finalize (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelService::finalize\n"); +} diff --git a/camel/camel-store.c b/camel/camel-store.c index a6fb1a303e..2168b3732c 100644 --- a/camel/camel-store.c +++ b/camel/camel-store.c @@ -22,6 +22,7 @@ */ #include #include "camel-store.h" +#include "camel-log.h" static CamelServiceClass *parent_class = NULL; @@ -35,10 +36,13 @@ static void _init(CamelStore *store, CamelSession *session, gchar *url_name); static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name); static gchar _get_separator (CamelStore *store); +static void _finalize (GtkObject *object); static void camel_store_class_init (CamelStoreClass *camel_store_class) { + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_store_class); + parent_class = gtk_type_class (camel_service_get_type ()); /* virtual method definition */ @@ -48,7 +52,9 @@ camel_store_class_init (CamelStoreClass *camel_store_class) camel_store_class->get_folder = _get_folder; camel_store_class->get_root_folder = _get_root_folder; camel_store_class->get_default_folder = _get_default_folder; + /* virtual method overload */ + gtk_object_class->finalize = _finalize; } @@ -122,11 +128,27 @@ _init (CamelStore *store, CamelSession *session, gchar *url_name) /* g_assert(session); */ g_assert(url_name); + if (store->session) gtk_object_unref (GTK_OBJECT (store->session)); store->session = session; + gtk_object_ref (GTK_OBJECT (session)); store->url_name = url_name; } +static void +_finalize (GtkObject *object) +{ + CamelStore *camel_store = CAMEL_STORE (object); + CAMEL_LOG_FULL_DEBUG ("Entering CamelStore::finalize\n"); + + if (camel_store->url_name) g_free (camel_store->url_name); + if (camel_store->session) gtk_object_unref (GTK_OBJECT (camel_store->session)); + + GTK_OBJECT_CLASS (parent_class)->finalize (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelStore::finalize\n"); +} + + /** * camel_store_set_separator: set the character which separates this folder path from the folders names in a lower level of hierarchy. diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index a8e0dcb6c4..340a87606c 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -43,11 +43,15 @@ static gboolean _eos (CamelStream *stream); static void _close (CamelStream *stream); static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); +static void _finalize (GtkObject *object); +static void _destroy (GtkObject *object); static void camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) { CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_fs_class); + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_fs_class); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ @@ -61,6 +65,9 @@ camel_stream_fs_class_init (CamelStreamFsClass *camel_stream_fs_class) camel_stream_class->close = _close; camel_stream_class->seek = _seek; + gtk_object_class->finalize = _finalize; + gtk_object_class->finalize = _destroy; + } @@ -90,6 +97,39 @@ camel_stream_fs_get_type (void) } +static void +_destroy (GtkObject *object) +{ + CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object); + gint close_error; + + CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamFs::destroy\n"); + + close_error = close (stream_fs->fd); + if (close_error) { + CAMEL_LOG_FULL_DEBUG ("CamelStreamFs::destroy Error while closing file descriptor\n"); + CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); + } + GTK_OBJECT_CLASS (parent_class)->destroy (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamFs::destroy\n"); +} + + +static void +_finalize (GtkObject *object) +{ + CamelStreamFs *stream_fs = CAMEL_STREAM_FS (object); + + + CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamFs::finalize\n"); + + if (stream_fs->name) g_free (stream_fs->name); + + GTK_OBJECT_CLASS (parent_class)->finalize (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamFs::finalize\n"); +} + + CamelStream * camel_stream_fs_new_with_name (gchar *name, CamelStreamFsMode mode) { diff --git a/camel/camel-stream-mem.c b/camel/camel-stream-mem.c index 2fa2c7c306..592caa5063 100644 --- a/camel/camel-stream-mem.c +++ b/camel/camel-stream-mem.c @@ -43,11 +43,14 @@ static gboolean _eos (CamelStream *stream); static void _close (CamelStream *stream); static gint _seek (CamelStream *stream, gint offset, CamelStreamSeekPolicy policy); +static void _finalize (GtkObject *object); static void camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) { CamelStreamClass *camel_stream_class = CAMEL_STREAM_CLASS (camel_stream_mem_class); + GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_stream_mem_class); + parent_class = gtk_type_class (gtk_object_get_type ()); /* virtual method definition */ @@ -61,6 +64,8 @@ camel_stream_mem_class_init (CamelStreamMemClass *camel_stream_mem_class) camel_stream_class->close = _close; camel_stream_class->seek = _seek; + gtk_object_class->finalize = _finalize; + } static void @@ -106,6 +111,20 @@ camel_stream_mem_new (CamelStreamMemMode mode) return CAMEL_STREAM (stream_mem); } +static void +_finalize (GtkObject *object) +{ + CamelStreamMem *stream_mem = CAMEL_STREAM_MEM (object); + + + CAMEL_LOG_FULL_DEBUG ("Entering CamelStreamMem::finalize\n"); + g_byte_array_free (stream_mem->buffer, TRUE); + + GTK_OBJECT_CLASS (parent_class)->finalize (object); + CAMEL_LOG_FULL_DEBUG ("Leaving CamelStreamMem::finalize\n"); +} + + /** * _read: read bytes from a stream -- cgit v1.2.3