mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 01:14:53 +01:00
CLI: centralize initialization in notmuch_client_init
Initially make sure gmime_filter_reply initialization is thread-safe (assuming notmuch_client_init is only called once). For tidyness, also put talloc initialization in the new function.
This commit is contained in:
parent
b1b6798588
commit
5a8d174f67
5 changed files with 29 additions and 27 deletions
|
@ -231,6 +231,7 @@ notmuch_client_srcs = \
|
|||
gmime-filter-reply.c \
|
||||
hooks.c \
|
||||
notmuch.c \
|
||||
notmuch-client-init.c \
|
||||
notmuch-compact.c \
|
||||
notmuch-config.c \
|
||||
notmuch-count.c \
|
||||
|
|
|
@ -43,29 +43,31 @@ static void filter_reset (GMimeFilter *filter);
|
|||
|
||||
|
||||
static GMimeFilterClass *parent_class = NULL;
|
||||
static GType type = 0;
|
||||
static const GTypeInfo info = {
|
||||
.class_size = sizeof (GMimeFilterReplyClass),
|
||||
.base_init = NULL,
|
||||
.base_finalize = NULL,
|
||||
.class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
|
||||
.class_finalize = NULL,
|
||||
.class_data = NULL,
|
||||
.instance_size = sizeof (GMimeFilterReply),
|
||||
.n_preallocs = 0,
|
||||
.instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
|
||||
.value_table = NULL,
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
g_mime_filter_reply_module_init (void)
|
||||
{
|
||||
type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
|
||||
parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
|
||||
}
|
||||
|
||||
GType
|
||||
g_mime_filter_reply_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type) {
|
||||
static const GTypeInfo info = {
|
||||
.class_size = sizeof (GMimeFilterReplyClass),
|
||||
.base_init = NULL,
|
||||
.base_finalize = NULL,
|
||||
.class_init = (GClassInitFunc) g_mime_filter_reply_class_init,
|
||||
.class_finalize = NULL,
|
||||
.class_data = NULL,
|
||||
.instance_size = sizeof (GMimeFilterReply),
|
||||
.n_preallocs = 0,
|
||||
.instance_init = (GInstanceInitFunc) g_mime_filter_reply_init,
|
||||
.value_table = NULL,
|
||||
};
|
||||
|
||||
type = g_type_register_static (GMIME_TYPE_FILTER, "GMimeFilterReply", &info, (GTypeFlags) 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -76,8 +78,6 @@ g_mime_filter_reply_class_init (GMimeFilterReplyClass *klass, unused (void *clas
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GMimeFilterClass *filter_class = GMIME_FILTER_CLASS (klass);
|
||||
|
||||
parent_class = (GMimeFilterClass *) g_type_class_ref (GMIME_TYPE_FILTER);
|
||||
|
||||
object_class->finalize = g_mime_filter_reply_finalize;
|
||||
|
||||
filter_class->copy = filter_copy;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
#include <gmime/gmime-filter.h>
|
||||
|
||||
void g_mime_filter_reply_module_init (void);
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GMIME_TYPE_FILTER_REPLY (g_mime_filter_reply_get_type ())
|
||||
|
|
|
@ -250,6 +250,10 @@ json_quote_chararray (const void *ctx, const char *str, const size_t len);
|
|||
char *
|
||||
json_quote_str (const void *ctx, const char *str);
|
||||
|
||||
/* notmuch-client-init.c */
|
||||
|
||||
void notmuch_client_init (void);
|
||||
|
||||
/* notmuch-config.c */
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -464,15 +464,10 @@ main (int argc, char *argv[])
|
|||
{ }
|
||||
};
|
||||
|
||||
talloc_enable_null_tracking ();
|
||||
notmuch_client_init ();
|
||||
|
||||
local = talloc_new (NULL);
|
||||
|
||||
g_mime_init ();
|
||||
#if ! GLIB_CHECK_VERSION (2, 35, 1)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
/* Globally default to the current output format version. */
|
||||
notmuch_format_version = NOTMUCH_FORMAT_CUR;
|
||||
|
||||
|
|
Loading…
Reference in a new issue