[libsecret/wip/nielsdg/g-autoptr-support] Add support for g_autoptr() to our types



commit c70e9d508c079d5d5fbab55e612100334c2bb068
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Jan 19 11:57:22 2019 +0100

    Add support for g_autoptr() to our types
    
    g_autoptr() is a macro that was defined in GLib 2.44 that allows for
    basic auto-cleanup of variables. One way to add this kind of support
    would be through the use of e.g. `G_DECLARE_DERIVABLE_TYPE()` for our
    declarations, but this would consitute an ABI break (due to the
    `...Private *` field in the public structs). Instead, we can use
    `G_DEFINE_AUTOPTR_CLEANUP_FUNC` to manually declare this.
    
    This commit also bumps the minimally required GLib version to 2.44

 configure.ac                  | 6 +++---
 libsecret/secret-collection.h | 2 ++
 libsecret/secret-item.h       | 2 ++
 libsecret/secret-private.h    | 4 ++++
 libsecret/secret-prompt.h     | 2 ++
 libsecret/secret-schema.h     | 2 ++
 libsecret/secret-service.h    | 2 ++
 libsecret/secret-value.h      | 2 ++
 8 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 09080e0..b1e6bcc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,9 +9,9 @@ dnl Dependency versions
 
 # Required
 
-GLIB_REQ=2.38.0
-GLIB_MIN=GLIB_VERSION_2_38
-GLIB_MAX=GLIB_VERSION_2_38
+GLIB_REQ=2.44.0
+GLIB_MIN=GLIB_VERSION_2_44
+GLIB_MAX=GLIB_VERSION_2_44
 
 # Optional
 
diff --git a/libsecret/secret-collection.h b/libsecret/secret-collection.h
index 55530f6..14d7d5f 100644
--- a/libsecret/secret-collection.h
+++ b/libsecret/secret-collection.h
@@ -173,6 +173,8 @@ guint64             secret_collection_get_created              (SecretCollection
 
 guint64             secret_collection_get_modified             (SecretCollection *self);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretCollection, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_COLLECTION_H___ */
diff --git a/libsecret/secret-item.h b/libsecret/secret-item.h
index e02c871..2742720 100644
--- a/libsecret/secret-item.h
+++ b/libsecret/secret-item.h
@@ -191,6 +191,8 @@ guint64             secret_item_get_created                (SecretItem *self);
 
 guint64             secret_item_get_modified               (SecretItem *self);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretItem, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_ITEM_H___ */
diff --git a/libsecret/secret-private.h b/libsecret/secret-private.h
index e563887..16f78ec 100644
--- a/libsecret/secret-private.h
+++ b/libsecret/secret-private.h
@@ -56,6 +56,8 @@ SecretSync *         _secret_sync_new                         (void);
 
 void                 _secret_sync_free                        (gpointer data);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSync, _secret_sync_free)
+
 void                 _secret_sync_on_result                   (GObject *source,
                                                                GAsyncResult *result,
                                                                gpointer user_data);
@@ -185,6 +187,8 @@ gchar *              _secret_value_unref_to_string            (SecretValue *valu
 
 void                 _secret_session_free                     (gpointer data);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSession, _secret_session_free)
+
 const gchar *        _secret_session_get_algorithms           (SecretSession *session);
 
 const gchar *        _secret_session_get_path                 (SecretSession *session);
diff --git a/libsecret/secret-prompt.h b/libsecret/secret-prompt.h
index 983c741..a8d1313 100644
--- a/libsecret/secret-prompt.h
+++ b/libsecret/secret-prompt.h
@@ -75,6 +75,8 @@ GVariant *          secret_prompt_perform_finish            (SecretPrompt *self,
                                                              GAsyncResult *result,
                                                              GError **error);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretPrompt, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_PROMPT_H___ */
diff --git a/libsecret/secret-schema.h b/libsecret/secret-schema.h
index 4039bd3..cd539a1 100644
--- a/libsecret/secret-schema.h
+++ b/libsecret/secret-schema.h
@@ -72,6 +72,8 @@ void              secret_schema_unref              (SecretSchema *schema);
 
 GType             secret_schema_attribute_get_type (void) G_GNUC_CONST;
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretSchema, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_SCHEMA_H___ */
diff --git a/libsecret/secret-service.h b/libsecret/secret-service.h
index e35f415..0e39186 100644
--- a/libsecret/secret-service.h
+++ b/libsecret/secret-service.h
@@ -304,6 +304,8 @@ gboolean             secret_service_set_alias_sync                (SecretService
                                                                    GCancellable *cancellable,
                                                                    GError **error);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretService, g_object_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_SERVICE_H___ */
diff --git a/libsecret/secret-value.h b/libsecret/secret-value.h
index baaff34..a36751e 100644
--- a/libsecret/secret-value.h
+++ b/libsecret/secret-value.h
@@ -51,6 +51,8 @@ SecretValue *       secret_value_ref               (SecretValue *value);
 
 void                secret_value_unref             (gpointer value);
 
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (SecretValue, secret_value_unref);
+
 G_END_DECLS
 
 #endif /* __SECRET_VALUE_H___ */


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