[gmime] code cleanup



commit 2d241fd82b9a66e78e4fef6a43c87e812bd59166
Author: Jeffrey Stedfast <jestedfa microsoft com>
Date:   Tue Feb 7 08:27:53 2017 -0500

    code cleanup

 gmime/Makefile.am             |    1 +
 gmime/gmime-charset.c         |   29 +++++++++++++++----
 gmime/gmime-header.c          |    3 +-
 gmime/gmime-iconv-utils.c     |   31 ++++++++++++++++++--
 gmime/gmime-iconv.c           |   30 +++++++++++++++----
 gmime/gmime-internal.h        |   62 +++++++++++++++++++++++++++++++++++++++++
 gmime/gmime-message-partial.c |    6 +---
 gmime/gmime-message.c         |   16 +----------
 gmime/gmime-multipart.c       |    5 +--
 gmime/gmime-object.c          |   11 +------
 gmime/gmime-parser-options.c  |   33 ++++++++++++++++------
 gmime/gmime-parser.c          |    4 +--
 gmime/gmime-part.c            |    5 +--
 gmime/gmime.c                 |   54 ++---------------------------------
 14 files changed, 170 insertions(+), 120 deletions(-)
---
diff --git a/gmime/Makefile.am b/gmime/Makefile.am
index 42d5127..59c8e70 100644
--- a/gmime/Makefile.am
+++ b/gmime/Makefile.am
@@ -136,6 +136,7 @@ noinst_HEADERS =                    \
        gmime-charset-map-private.h     \
        gmime-table-private.h           \
        gmime-parse-utils.h             \
+       gmime-internal.h                \
        gmime-common.h                  \
        gmime-events.h
 
diff --git a/gmime/gmime-charset.c b/gmime/gmime-charset.c
index afdbbe1..8fc17e3 100644
--- a/gmime/gmime-charset.c
+++ b/gmime/gmime-charset.c
@@ -168,12 +168,12 @@ static GHashTable *iconv_charsets = NULL;
 static char **user_charsets = NULL;
 static char *locale_charset = NULL;
 static char *locale_lang = NULL;
+static int initialized = 0;
 
 #ifdef G_THREADS_ENABLED
-extern void _g_mime_charset_unlock (void);
-extern void _g_mime_charset_lock (void);
-#define CHARSET_UNLOCK() _g_mime_charset_unlock ()
-#define CHARSET_LOCK()   _g_mime_charset_lock ()
+G_LOCK_DEFINE_STATIC (lock);
+#define CHARSET_UNLOCK() G_UNLOCK (lock)
+#define CHARSET_LOCK() G_UNLOCK (lock)
 #else
 #define CHARSET_UNLOCK()
 #define CHARSET_LOCK()
@@ -188,9 +188,20 @@ extern void _g_mime_charset_lock (void);
 void
 g_mime_charset_map_shutdown (void)
 {
-       if (!iconv_charsets)
+       if (--initialized)
                return;
        
+#ifdef G_THREADS_ENABLED
+       if (glib_check_version (2, 37, 4) == NULL) {
+               /* The implementation of g_mutex_clear() prior
+                * to glib 2.37.4 did not properly reset the
+                * internal mutex pointer to NULL, so re-initializing
+                * GMime would not properly re-initialize the mutexes.
+                **/
+               g_mutex_clear (&G_LOCK_NAME (lock));
+       }
+#endif
+       
        g_hash_table_destroy (iconv_charsets);
        iconv_charsets = NULL;
        
@@ -256,8 +267,14 @@ g_mime_charset_map_init (void)
        char *charset, *iconv_name, *locale;
        int i;
        
-       if (iconv_charsets)
+       initialized = MAX (initialized, 0);
+       
+       if (initialized++)
                return;
+
+#ifdef G_THREADS_ENABLED
+       g_mutex_init (&G_LOCK_NAME (lock));
+#endif
        
        iconv_charsets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
        
diff --git a/gmime/gmime-header.c b/gmime/gmime-header.c
index a9479b7..ef09f11 100644
--- a/gmime/gmime-header.c
+++ b/gmime/gmime-header.c
@@ -27,6 +27,7 @@
 #include <ctype.h>
 
 #include "gmime-stream-mem.h"
+#include "gmime-internal.h"
 #include "gmime-common.h"
 #include "gmime-header.h"
 #include "gmime-events.h"
@@ -45,8 +46,6 @@
  * values.
  **/
 
-extern GMimeParserOptions *_g_mime_parser_options_clone (GMimeParserOptions *options);
-
 struct _GMimeHeader {
        GMimeHeaderList *list;
        gint64 offset;
diff --git a/gmime/gmime-iconv-utils.c b/gmime/gmime-iconv-utils.c
index 94ddf36..6a2595b 100644
--- a/gmime/gmime-iconv-utils.c
+++ b/gmime/gmime-iconv-utils.c
@@ -48,10 +48,9 @@
 
 
 #ifdef G_THREADS_ENABLED
-extern void _g_mime_iconv_utils_unlock (void);
-extern void _g_mime_iconv_utils_lock (void);
-#define UNLOCK() _g_mime_iconv_utils_unlock ()
-#define LOCK()   _g_mime_iconv_utils_lock ()
+G_LOCK_DEFINE_STATIC (iconv_utils);
+#define UNLOCK() G_UNLOCK (iconv_utils)
+#define LOCK()   G_LOCK (iconv_utils)
 #else
 #define UNLOCK()
 #define LOCK()
@@ -59,6 +58,7 @@ extern void _g_mime_iconv_utils_lock (void);
 
 static iconv_t utf8_to_locale = (iconv_t) -1;
 static iconv_t locale_to_utf8 = (iconv_t) -1;
+static int initialized = 0;
 
 
 void
@@ -66,6 +66,15 @@ g_mime_iconv_utils_init (void)
 {
        const char *utf8, *locale;
        
+       initialized = MAX (initialized, 0);
+       
+       if (initialized++)
+               return;
+       
+#ifdef G_THREADS_ENABLED
+       g_mutex_init (&G_LOCK_NAME (iconv_utils));
+#endif
+       
        utf8 = g_mime_charset_iconv_name ("UTF-8");
        
        if (!(locale = g_mime_locale_charset ()))
@@ -80,6 +89,20 @@ g_mime_iconv_utils_init (void)
 void
 g_mime_iconv_utils_shutdown (void)
 {
+       if (--initialized)
+               return;
+       
+#ifdef G_THREADS_ENABLED
+       if (glib_check_version (2, 37, 4) == NULL) {
+               /* The implementation of g_mutex_clear() prior
+                * to glib 2.37.4 did not properly reset the
+                * internal mutex pointer to NULL, so re-initializing
+                * GMime would not properly re-initialize the mutexes.
+                **/
+               g_mutex_clear (&G_LOCK_NAME (iconv_utils));
+       }
+#endif
+       
        if (utf8_to_locale != (iconv_t) -1) {
                iconv_close (utf8_to_locale);
                utf8_to_locale = (iconv_t) -1;
diff --git a/gmime/gmime-iconv.c b/gmime/gmime-iconv.c
index 8e4e5f5..259025c 100644
--- a/gmime/gmime-iconv.c
+++ b/gmime/gmime-iconv.c
@@ -57,7 +57,6 @@
  * names given as arguments.
  **/
 
-
 #define ICONV_CACHE_SIZE   (16)
 
 typedef struct {
@@ -70,6 +69,7 @@ typedef struct {
 
 static Cache *iconv_cache = NULL;
 static GHashTable *iconv_open_hash = NULL;
+static int initialized = 0;
 
 #ifdef GMIME_ICONV_DEBUG
 static int cache_misses = 0;
@@ -80,10 +80,9 @@ static int shutdown = 0;
 #endif /* GMIME_ICONV_DEBUG */
 
 #ifdef G_THREADS_ENABLED
-extern void _g_mime_iconv_cache_unlock (void);
-extern void _g_mime_iconv_cache_lock (void);
-#define ICONV_CACHE_UNLOCK() _g_mime_iconv_cache_unlock ()
-#define ICONV_CACHE_LOCK()   _g_mime_iconv_cache_lock ()
+G_LOCK_DEFINE_STATIC (lock);
+#define ICONV_CACHE_UNLOCK() G_UNLOCK (lock)
+#define ICONV_CACHE_LOCK()   G_LOCK (lock)
 #else
 #define ICONV_CACHE_UNLOCK()
 #define ICONV_CACHE_LOCK()
@@ -181,7 +180,7 @@ iconv_open_node_free (gpointer key, gpointer value, gpointer user_data)
 void
 g_mime_iconv_shutdown (void)
 {
-       if (!iconv_cache)
+       if (--initialized)
                return;
        
 #ifdef GMIME_ICONV_DEBUG
@@ -190,6 +189,17 @@ g_mime_iconv_shutdown (void)
        shutdown = 1;
 #endif
        
+#ifdef G_THREADS_ENABLED
+       if (glib_check_version (2, 37, 4) == NULL) {
+               /* The implementation of g_mutex_clear() prior
+                * to glib 2.37.4 did not properly reset the
+                * internal mutex pointer to NULL, so re-initializing
+                * GMime would not properly re-initialize the mutexes.
+                **/
+               g_mutex_clear (&G_LOCK_NAME (lock));
+       }
+#endif
+       
        g_hash_table_foreach (iconv_open_hash, iconv_open_node_free, NULL);
        g_hash_table_destroy (iconv_open_hash);
        iconv_open_hash = NULL;
@@ -210,9 +220,15 @@ g_mime_iconv_shutdown (void)
 void
 g_mime_iconv_init (void)
 {
-       if (iconv_cache)
+       initialized = MAX (initialized, 0);
+       
+       if (initialized++)
                return;
        
+#ifdef G_THREADS_ENABLED
+       g_mutex_init (&G_LOCK_NAME (lock));
+#endif
+       
        g_mime_charset_map_init ();
        
        iconv_open_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
diff --git a/gmime/gmime-internal.h b/gmime/gmime-internal.h
new file mode 100644
index 0000000..0294562
--- /dev/null
+++ b/gmime/gmime-internal.h
@@ -0,0 +1,62 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*  GMime
+ *  Copyright (C) 2000-2014 Jeffrey Stedfast
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public License
+ *  as published by the Free Software Foundation; either version 2.1
+ *  of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free
+ *  Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+ *  02110-1301, USA.
+ */
+
+
+#ifndef __GMIME_INTERNAL_H__
+#define __GMIME_INTERNAL_H__
+
+#include <gmime/gmime-parser-options.h>
+#include <gmime/gmime-object.h>
+#include <gmime/gmime-events.h>
+#include <gmime/gmime-utils.h>
+
+G_BEGIN_DECLS
+
+/* GMimeParserOptions */
+G_GNUC_INTERNAL void _g_mime_parser_options_init (void);
+G_GNUC_INTERNAL void _g_mime_parser_options_shutdown (void);
+G_GNUC_INTERNAL GMimeParserOptions *_g_mime_parser_options_clone (GMimeParserOptions *options);
+
+/* GMimeHeader */
+G_GNUC_INTERNAL const char *_g_mime_header_get_raw_value (GMimeHeader *header);
+G_GNUC_INTERNAL void _g_mime_header_set_offset (GMimeHeader *header, gint64 offset);
+
+/* GMimeHeaderList */
+G_GNUC_INTERNAL GMimeParserOptions *_g_mime_header_list_get_options (GMimeHeaderList *headers);
+G_GNUC_INTERNAL void _g_mime_header_list_set_options (GMimeHeaderList *headers, GMimeParserOptions *options);
+G_GNUC_INTERNAL gboolean _g_mime_header_list_has_raw_value (const GMimeHeaderList *headers, const char 
*name);
+G_GNUC_INTERNAL void _g_mime_header_list_prepend (GMimeHeaderList *headers, const char *name, const char 
*value, const char *raw_value, gint64 offset);
+G_GNUC_INTERNAL void _g_mime_header_list_append (GMimeHeaderList *headers, const char *name, const char 
*value, const char *raw_value, gint64 offset);
+G_GNUC_INTERNAL void _g_mime_header_list_set (GMimeHeaderList *headers, const char *name, const char *value, 
const char *raw_value, gint64 offset);
+G_GNUC_INTERNAL GMimeEvent *_g_mime_header_list_get_changed_event (GMimeHeaderList *headers);
+
+/* GMimeObject */
+G_GNUC_INTERNAL void _g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *content_type);
+G_GNUC_INTERNAL void _g_mime_object_prepend_header (GMimeObject *object, const char *header, const char 
*value, const char *raw_value, gint64 offset);
+G_GNUC_INTERNAL void _g_mime_object_append_header (GMimeObject *object, const char *header, const char 
*value, const char *raw_value, gint64 offset);
+G_GNUC_INTERNAL void _g_mime_object_set_header (GMimeObject *object, const char *header, const char *value, 
const char *raw_value, gint64 offset);
+
+/* utils */
+G_GNUC_INTERNAL char *_g_mime_utils_unstructured_header_fold (GMimeParserOptions *options, const char 
*field, const char *value);
+G_GNUC_INTERNAL char *_g_mime_utils_structured_header_fold (GMimeParserOptions *options, const char *field, 
const char *value);
+
+G_END_DECLS
+
+#endif /* __GMIME_INTERNAL_H__ */
diff --git a/gmime/gmime-message-partial.c b/gmime/gmime-message-partial.c
index 32dbf02..d6f6759 100644
--- a/gmime/gmime-message-partial.c
+++ b/gmime/gmime-message-partial.c
@@ -29,6 +29,7 @@
 #include "gmime-message-partial.h"
 #include "gmime-stream-cat.h"
 #include "gmime-stream-mem.h"
+#include "gmime-internal.h"
 #include "gmime-parser.h"
 
 
@@ -41,11 +42,6 @@
  * A #GMimeMessagePartial represents the message/partial MIME part.
  **/
 
-extern const char *_g_mime_header_get_raw_value (GMimeHeader *header);
-
-extern void _g_mime_object_append_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
-
-
 /* GObject class methods */
 static void g_mime_message_partial_class_init (GMimeMessagePartialClass *klass);
 static void g_mime_message_partial_init (GMimeMessagePartial *catpart, GMimeMessagePartialClass *klass);
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index ded2555..cf40719 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -37,6 +37,7 @@
 #include "gmime-stream-mem.h"
 #include "gmime-table-private.h"
 #include "gmime-parse-utils.h"
+#include "gmime-internal.h"
 #include "gmime-events.h"
 
 
@@ -49,21 +50,6 @@
  * A #GMimeMessage represents an rfc822 message.
  **/
 
-extern void _g_mime_object_prepend_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_object_append_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_object_set_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
-
-extern void _g_mime_header_set_offset (GMimeHeader *header, gint64 offset);
-
-extern GMimeParserOptions *_g_mime_header_list_get_options (GMimeHeaderList *headers);
-extern void _g_mime_header_list_prepend (GMimeHeaderList *headers, const char *name, const char *value, 
const char *raw_value, gint64 offset);
-extern void _g_mime_header_list_append (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_header_list_set (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-
-extern GMimeEvent *_g_mime_header_list_get_changed_event (GMimeHeaderList *headers);
-extern char *_g_mime_utils_unstructured_header_fold (GMimeParserOptions *options, const char *field, const 
char *value);
-extern char *_g_mime_utils_structured_header_fold (GMimeParserOptions *options, const char *field, const 
char *value);
-
 static void g_mime_message_class_init (GMimeMessageClass *klass);
 static void g_mime_message_init (GMimeMessage *message, GMimeMessageClass *klass);
 static void g_mime_message_finalize (GObject *object);
diff --git a/gmime/gmime-multipart.c b/gmime/gmime-multipart.c
index 6a77456..7e1c446 100644
--- a/gmime/gmime-multipart.c
+++ b/gmime/gmime-multipart.c
@@ -33,6 +33,7 @@
 #include <time.h>
 
 #include "gmime-multipart.h"
+#include "gmime-internal.h"
 #include "gmime-utils.h"
 
 
@@ -48,10 +49,6 @@
  * A #GMimeMultipart represents all multipart MIME container parts.
  **/
 
-
-extern gboolean _g_mime_header_list_has_raw_value (const GMimeHeaderList *headers, const char *name);
-
-
 /* GObject class methods */
 static void g_mime_multipart_class_init (GMimeMultipartClass *klass);
 static void g_mime_multipart_init (GMimeMultipart *multipart, GMimeMultipartClass *klass);
diff --git a/gmime/gmime-object.c b/gmime/gmime-object.c
index 6bc99b1..d95d69d 100644
--- a/gmime/gmime-object.c
+++ b/gmime/gmime-object.c
@@ -29,6 +29,7 @@
 #include "gmime-common.h"
 #include "gmime-object.h"
 #include "gmime-stream-mem.h"
+#include "gmime-internal.h"
 #include "gmime-events.h"
 #include "gmime-utils.h"
 
@@ -43,7 +44,6 @@
  * parts are derived.
  **/
 
-
 struct _type_bucket {
        char *type;
        GType object_type;
@@ -55,15 +55,6 @@ struct _subtype_bucket {
        GType object_type;
 };
 
-extern GMimeParserOptions *_g_mime_parser_options_clone (GMimeParserOptions *options);
-
-extern GMimeParserOptions *_g_mime_header_list_get_options (GMimeHeaderList *headers);
-extern void _g_mime_header_list_set_options (GMimeHeaderList *headers, GMimeParserOptions *options);
-
-extern void _g_mime_header_list_prepend (GMimeHeaderList *headers, const char *name, const char *value, 
const char *raw_value, gint64 offset);
-extern void _g_mime_header_list_append (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_header_list_set (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-
 static void _g_mime_object_set_content_disposition (GMimeObject *object, GMimeContentDisposition 
*disposition);
 void _g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *content_type);
 
diff --git a/gmime/gmime-parser-options.c b/gmime/gmime-parser-options.c
index 5080ba4..22570ff 100644
--- a/gmime/gmime-parser-options.c
+++ b/gmime/gmime-parser-options.c
@@ -29,13 +29,26 @@
 
 static char *default_charsets[3] = { "utf-8", "iso-8859-1", NULL };
 
+static GMimeParserOptions *default_options = NULL;
 
-static GMimeParserOptions g_mime_parser_options_default = {
-       GMIME_RFC_COMPLIANCE_LOOSE,
-       GMIME_RFC_COMPLIANCE_LOOSE,
-       GMIME_RFC_COMPLIANCE_LOOSE,
-       default_charsets
-};
+
+void
+_g_mime_parser_options_init (void)
+{
+       if (default_options == NULL)
+               default_options = g_mime_parser_options_new ();
+}
+
+void
+_g_mime_parser_options_shutdown (void)
+{
+       if (default_options == NULL)
+               return;
+       
+       g_strfreev (default_options->charsets);
+       g_slice_free (GMimeParserOptions, default_options);
+       default_options = NULL;
+}
 
 
 /**
@@ -48,7 +61,7 @@ static GMimeParserOptions g_mime_parser_options_default = {
 GMimeParserOptions *
 g_mime_parser_options_get_default (void)
 {
-       return &g_mime_parser_options_default;
+       return default_options;
 }
 
 
@@ -120,8 +133,10 @@ g_mime_parser_options_free (GMimeParserOptions *options)
 {
        g_return_if_fail (options != NULL);
        
-       g_strfreev (options->charsets);
-       g_slice_free (GMimeParserOptions, options);
+       if (options != default_options) {
+               g_strfreev (options->charsets);
+               g_slice_free (GMimeParserOptions, options);
+       }
 }
 
 
diff --git a/gmime/gmime-parser.c b/gmime/gmime-parser.c
index 08d0591..c318f08 100644
--- a/gmime/gmime-parser.c
+++ b/gmime/gmime-parser.c
@@ -34,6 +34,7 @@
 #include "gmime-parse-utils.h"
 #include "gmime-stream-mem.h"
 #include "gmime-multipart.h"
+#include "gmime-internal.h"
 #include "gmime-common.h"
 #include "gmime-part.h"
 
@@ -83,9 +84,6 @@ typedef struct _content_type {
        gboolean exists;
 } ContentType;
 
-extern void _g_mime_object_append_header (GMimeObject *object, const char *header, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_object_set_content_type (GMimeObject *object, GMimeContentType *content_type);
-
 static void g_mime_parser_class_init (GMimeParserClass *klass);
 static void g_mime_parser_init (GMimeParser *parser, GMimeParserClass *klass);
 static void g_mime_parser_finalize (GObject *object);
diff --git a/gmime/gmime-part.c b/gmime/gmime-part.c
index 8b30526..c5924ae 100644
--- a/gmime/gmime-part.c
+++ b/gmime/gmime-part.c
@@ -30,6 +30,7 @@
 #include "gmime-part.h"
 #include "gmime-utils.h"
 #include "gmime-common.h"
+#include "gmime-internal.h"
 #include "gmime-stream-mem.h"
 #include "gmime-stream-null.h"
 #include "gmime-stream-filter.h"
@@ -52,10 +53,6 @@
  * sub-parts).
  **/
 
-extern void _g_mime_header_list_prepend (GMimeHeaderList *headers, const char *name, const char *value, 
const char *raw_value, gint64 offset);
-extern void _g_mime_header_list_append (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-extern void _g_mime_header_list_set (GMimeHeaderList *headers, const char *name, const char *value, const 
char *raw_value, gint64 offset);
-
 /* GObject class methods */
 static void g_mime_part_class_init (GMimePartClass *klass);
 static void g_mime_part_init (GMimePart *mime_part, GMimePartClass *klass);
diff --git a/gmime/gmime.c b/gmime/gmime.c
index 29cdcc8..564e453 100644
--- a/gmime/gmime.c
+++ b/gmime/gmime.c
@@ -31,6 +31,7 @@
 #endif
 
 #include "gmime.h"
+#include "gmime-internal.h"
 
 #ifdef ENABLE_CRYPTOGRAPHY
 #include "gmime-pkcs7-context.h"
@@ -52,12 +53,6 @@ extern gboolean _g_mime_use_only_user_charsets (void);
 extern void g_mime_iconv_utils_shutdown (void);
 extern void g_mime_iconv_utils_init (void);
 
-extern void _g_mime_iconv_cache_unlock (void);
-extern void _g_mime_iconv_cache_lock (void);
-extern void _g_mime_iconv_utils_unlock (void);
-extern void _g_mime_iconv_utils_lock (void);
-extern void _g_mime_charset_unlock (void);
-extern void _g_mime_charset_lock (void);
 extern void _g_mime_msgid_unlock (void);
 extern void _g_mime_msgid_lock (void);
 
@@ -70,9 +65,6 @@ const guint gmime_micro_version = GMIME_MICRO_VERSION;
 const guint gmime_interface_age = GMIME_INTERFACE_AGE;
 const guint gmime_binary_age = GMIME_BINARY_AGE;
 
-G_LOCK_DEFINE_STATIC (iconv_cache);
-G_LOCK_DEFINE_STATIC (iconv_utils);
-G_LOCK_DEFINE_STATIC (charset);
 G_LOCK_DEFINE_STATIC (msgid);
 
 static unsigned int initialized = 0;
@@ -118,6 +110,8 @@ g_mime_check_version (guint major, guint minor, guint micro)
 void
 g_mime_init (guint32 flags)
 {
+       initialized = MAX (initialized, 0);
+       
        if (initialized++)
                return;
 
@@ -136,9 +130,6 @@ g_mime_init (guint32 flags)
 #endif
        
 #ifdef G_THREADS_ENABLED
-       g_mutex_init (&G_LOCK_NAME (iconv_cache));
-       g_mutex_init (&G_LOCK_NAME (iconv_utils));
-       g_mutex_init (&G_LOCK_NAME (charset));
        g_mutex_init (&G_LOCK_NAME (msgid));
 #endif
        
@@ -240,9 +231,6 @@ g_mime_shutdown (void)
                 * internal mutex pointer to NULL, so re-initializing
                 * GMime would not properly re-initialize the mutexes.
                 **/
-               g_mutex_clear (&G_LOCK_NAME (iconv_cache));
-               g_mutex_clear (&G_LOCK_NAME (iconv_utils));
-               g_mutex_clear (&G_LOCK_NAME (charset));
                g_mutex_clear (&G_LOCK_NAME (msgid));
        }
 #endif
@@ -256,42 +244,6 @@ _g_mime_use_only_user_charsets (void)
 }
 
 void
-_g_mime_iconv_cache_unlock (void)
-{
-       return G_UNLOCK (iconv_cache);
-}
-
-void
-_g_mime_iconv_cache_lock (void)
-{
-       return G_LOCK (iconv_cache);
-}
-
-void
-_g_mime_iconv_utils_unlock (void)
-{
-       return G_UNLOCK (iconv_utils);
-}
-
-void
-_g_mime_iconv_utils_lock (void)
-{
-       return G_LOCK (iconv_utils);
-}
-
-void
-_g_mime_charset_unlock (void)
-{
-       return G_UNLOCK (charset);
-}
-
-void
-_g_mime_charset_lock (void)
-{
-       return G_LOCK (charset);
-}
-
-void
 _g_mime_msgid_unlock (void)
 {
        return G_UNLOCK (msgid);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]