[gnome-software: 3/7] gs-app: Squash empty arrays to NULL in gs_app_set_version_history()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 3/7] gs-app: Squash empty arrays to NULL in gs_app_set_version_history()
- Date: Fri, 30 Apr 2021 12:08:49 +0000 (UTC)
commit e5c025e7e4349d32da617eaac0cd948be8ce3832
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Apr 29 15:46:39 2021 +0100
gs-app: Squash empty arrays to NULL in gs_app_set_version_history()
This should save a little bit of memory. I have not updated the
documentation to guarantee this behaviour because it’s a little unusual;
simpler to allow callers to continue handling `NULL` and empty array
cases explicitly.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1227
lib/gs-app.c | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/lib/gs-app.c b/lib/gs-app.c
index 89ad33470..c833ff432 100644
--- a/lib/gs-app.c
+++ b/lib/gs-app.c
@@ -5378,6 +5378,10 @@ gs_app_set_version_history (GsApp *app, GPtrArray *version_history)
GsAppPrivate *priv = gs_app_get_instance_private (app);
g_autoptr(GMutexLocker) locker = NULL;
g_return_if_fail (GS_IS_APP (app));
+
+ if (version_history != NULL && version_history->len == 0)
+ version_history = NULL;
+
locker = g_mutex_locker_new (&priv->mutex);
_g_set_ptr_array (&priv->version_history, version_history);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]