[file-roller/wip/jtojnar/engrampa-backports: 9/21] glib-utils: Remove useless GPtrArray functions
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/engrampa-backports: 9/21] glib-utils: Remove useless GPtrArray functions
- Date: Wed, 27 Jul 2022 02:04:04 +0000 (UTC)
commit a696bda5fe1f13ddf83fa4de1f933a7b90414c0c
Author: Jan Tojnar <jtojnar gmail com>
Date: Sat Aug 24 12:21:31 2019 +0200
glib-utils: Remove useless GPtrArray functions
Most of those are unused and we can replace _g_ptr_array_free_full by unref'ing and setting cleanup
method on construction.
Inspired by https://github.com/mate-desktop/engrampa/commit/e1df6882d62bb1f0c700f3ee2d480c32d988eab5
src/fr-archive.c | 8 +++----
src/glib-utils.c | 68 --------------------------------------------------------
src/glib-utils.h | 11 ---------
3 files changed, 4 insertions(+), 83 deletions(-)
---
diff --git a/src/fr-archive.c b/src/fr-archive.c
index 52d757e8..04c48630 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -246,7 +246,7 @@ fr_archive_finalize (GObject *object)
}
g_mutex_clear (&archive->priv->progress_mutex);
g_hash_table_unref (archive->files_hash);
- _g_ptr_array_free_full (archive->files, (GFunc) file_data_free, NULL);
+ g_ptr_array_unref (archive->files);
if (archive->priv->dropped_items_data != NULL) {
dropped_items_data_free (archive->priv->dropped_items_data);
archive->priv->dropped_items_data = NULL;
@@ -432,7 +432,7 @@ fr_archive_init (FrArchive *self)
self->priv = fr_archive_get_instance_private (self);
self->mime_type = NULL;
- self->files = g_ptr_array_sized_new (FILE_ARRAY_INITIAL_SIZE);
+ self->files = g_ptr_array_new_full (FILE_ARRAY_INITIAL_SIZE, (GDestroyNotify) file_data_free);
self->files_hash = g_hash_table_new (g_str_hash, g_str_equal);
self->n_regular_files = 0;
self->password = NULL;
@@ -854,8 +854,8 @@ fr_archive_list (FrArchive *archive,
if (archive->files != NULL) {
g_hash_table_remove_all (archive->files_hash);
- _g_ptr_array_free_full (archive->files, (GFunc) file_data_free, NULL);
- archive->files = g_ptr_array_sized_new (FILE_ARRAY_INITIAL_SIZE);
+ g_ptr_array_unref (archive->files);
+ archive->files = g_ptr_array_new_full (FILE_ARRAY_INITIAL_SIZE, (GDestroyNotify)
file_data_free);
archive->n_regular_files = 0;
}
diff --git a/src/glib-utils.c b/src/glib-utils.c
index b417ddd6..2ebc38ad 100644
--- a/src/glib-utils.c
+++ b/src/glib-utils.c
@@ -480,74 +480,6 @@ _g_string_list_dup (GList *path_list)
}
-/* GPtrArray */
-
-
-GPtrArray *
-_g_ptr_array_copy (GPtrArray *array)
-{
- GPtrArray *new_array;
-
- if (array == NULL)
- return NULL;
-
- new_array = g_ptr_array_sized_new (array->len);
- memcpy (new_array->pdata, array->pdata, array->len * sizeof (gpointer));
- new_array->len = array->len;
-
- return new_array;
-}
-
-
-void
-_g_ptr_array_free_full (GPtrArray *array,
- GFunc free_func,
- gpointer user_data)
-{
- g_ptr_array_foreach (array, free_func, user_data);
- g_ptr_array_free (array, TRUE);
-}
-
-
-void
-_g_ptr_array_reverse (GPtrArray *array)
-{
- int i, j;
- gpointer tmp;
-
- for (i = 0; i < array->len / 2; i++) {
- j = array->len - i - 1;
- tmp = g_ptr_array_index (array, i);
- g_ptr_array_index (array, i) = g_ptr_array_index (array, j);
- g_ptr_array_index (array, j) = tmp;
- }
-}
-
-
-int
-_g_ptr_array_binary_search (GPtrArray *array,
- gpointer value,
- GCompareFunc func)
-{
- int l, r, p, cmp = -1;
-
- l = 0;
- r = array->len;
- while (l < r) {
- p = l + ((r - l) / 2);
- cmp = func(value, &g_ptr_array_index (array, p));
- if (cmp == 0)
- return p;
- else if (cmp < 0)
- r = p;
- else
- l = p + 1;
- }
-
- return -1;
-}
-
-
/* GRegex */
diff --git a/src/glib-utils.h b/src/glib-utils.h
index 94893aa2..2c7eaa39 100644
--- a/src/glib-utils.h
+++ b/src/glib-utils.h
@@ -106,17 +106,6 @@ gboolean _g_strv_remove (char **str_arr
void _g_string_list_free (GList *path_list);
GList * _g_string_list_dup (GList *path_list);
-/* GPtrArray */
-
-GPtrArray * _g_ptr_array_copy (GPtrArray *array);
-void _g_ptr_array_free_full (GPtrArray *array,
- GFunc func,
- gpointer user_data);
-void _g_ptr_array_reverse (GPtrArray *array);
-int _g_ptr_array_binary_search (GPtrArray *array,
- gpointer value,
- GCompareFunc func);
-
/* GRegex */
gboolean _g_regexp_matchv (GRegex **regexps,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]