[gcr/main: 21/30] gck: Use the G_DEFINE_QUARK macro




commit 46656d972f6e0d17938e7a5a026135c393a80ab8
Author: Corentin Noël <corentin elementary io>
Date:   Sun Feb 6 23:26:01 2022 +0100

    gck: Use the G_DEFINE_QUARK macro
    
    Automatically define the error quark with this macro.

 gck/gck-misc.c | 15 +--------------
 gck/gck-uri.c  | 14 +-------------
 gck/gck.h      |  8 ++++----
 3 files changed, 6 insertions(+), 31 deletions(-)
---
diff --git a/gck/gck-misc.c b/gck/gck-misc.c
index 2c864a1f..ef8a19b7 100644
--- a/gck/gck-misc.c
+++ b/gck/gck-misc.c
@@ -101,20 +101,7 @@ EGG_SECURE_DEFINE_GLIB_GLOBALS ();
  *
  * The error domain for gck library errors.
  */
-
-GQuark
-gck_error_get_quark (void)
-{
-       static GQuark domain = 0;
-       static size_t quark_inited = 0;
-
-       if (g_once_init_enter (&quark_inited)) {
-               domain = g_quark_from_static_string ("gck-error");
-               g_once_init_leave (&quark_inited, 1);
-       }
-
-       return domain;
-}
+G_DEFINE_QUARK(GckError, gck_error)
 
 /**
  * gck_message_from_rv:
diff --git a/gck/gck-uri.c b/gck/gck-uri.c
index 3cc0dc8b..69459808 100644
--- a/gck/gck-uri.c
+++ b/gck/gck-uri.c
@@ -106,19 +106,7 @@ struct _GckUri {
        GckAttributes *attributes;
 };
 
-GQuark
-gck_uri_error_get_quark (void)
-{
-       static GQuark domain = 0;
-       static size_t quark_inited = 0;
-
-       if (g_once_init_enter (&quark_inited)) {
-               domain = g_quark_from_static_string ("gck-uri-error");
-               g_once_init_leave (&quark_inited, 1);
-       }
-
-       return domain;
-}
+G_DEFINE_QUARK(GckUriError, gck_uri_error)
 
 /**
  * gck_uri_data_new:
diff --git a/gck/gck.h b/gck/gck.h
index 172cd4b7..b22d2ca5 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -54,9 +54,9 @@ typedef enum {
        GCK_ERROR_MODULE_PROBLEM = (CKR_VENDOR_DEFINED | (GCK_VENDOR_CODE + 1)),
 } GckError;
 
-#define             GCK_ERROR                               (gck_error_get_quark ())
+#define             GCK_ERROR                               (gck_error_quark ())
 
-GQuark              gck_error_get_quark                     (void) G_GNUC_CONST;
+GQuark              gck_error_quark                         (void) G_GNUC_CONST;
 
 #define             GCK_TYPE_LIST                           (gck_list_get_boxed_type ())
 
@@ -1566,9 +1566,9 @@ struct _GckUriData {
        gpointer dummy[4];
 };
 
-#define             GCK_URI_ERROR                           (gck_uri_error_get_quark ())
+#define             GCK_URI_ERROR                           (gck_uri_error_quark ())
 
-GQuark              gck_uri_error_get_quark                 (void) G_GNUC_CONST;
+GQuark              gck_uri_error_quark                     (void) G_GNUC_CONST;
 
 GckUriData*         gck_uri_data_new                        (void);
 


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