[gnome-photos/gnome-3-20] Add photos_utils_set_string
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/gnome-3-20] Add photos_utils_set_string
- Date: Wed, 24 Aug 2016 15:54:44 +0000 (UTC)
commit da97574d8d8aaeed4baae5c86dc04319546371d4
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Jul 9 14:33:00 2016 +0200
Add photos_utils_set_string
This is similar to g_set_object, but for C strings.
Based on an implementation by Emmanuele Bassi.
https://bugzilla.gnome.org/show_bug.cgi?id=768548
src/photos-utils.c | 23 +++++++++++++++++++++++
src/photos-utils.h | 2 ++
2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 0e5951a..1fc46d9 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1450,3 +1450,26 @@ photos_utils_set_favorite (const gchar *urn, gboolean is_favorite)
g_free (sparql);
g_clear_object (&queue);
}
+
+
+gboolean
+photos_utils_set_string (gchar **string_ptr, const gchar *new_string)
+{
+ gboolean ret_val = FALSE;
+
+ g_return_val_if_fail (string_ptr != NULL, FALSE);
+
+ if (*string_ptr == new_string)
+ goto out;
+
+ if (g_strcmp0 (*string_ptr, new_string) == 0)
+ goto out;
+
+ g_free (*string_ptr);
+ *string_ptr = g_strdup (new_string);
+
+ ret_val = TRUE;
+
+ out:
+ return ret_val;
+}
diff --git a/src/photos-utils.h b/src/photos-utils.h
index b788e4d..184ecff 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -176,6 +176,8 @@ void photos_utils_set_edited_name (const gchar *urn, con
void photos_utils_set_favorite (const gchar *urn, gboolean is_favorite);
+gboolean photos_utils_set_string (gchar **string_ptr, const gchar *new_string);
+
G_END_DECLS
#endif /* PHOTOS_UTILS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]