After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 631210 - Missing strv functions
Missing strv functions
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
: 708250 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-10-03 07:17 UTC by Sergey V. Udaltsov
Modified: 2018-05-24 12:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal set of useful additions (713 bytes, text/plain)
2010-10-04 10:14 UTC, Sergey V. Udaltsov
Details

Description Sergey V. Udaltsov 2010-10-03 07:17:09 UTC
There is very useful data type half-supported by glib - the NULL-ended array of pointers to strings. Some functions are missing:
- insert at position
- delete at position
- search
It is not a problem to implement them when they are needed - but perhaps it would be useful to have them in glib code
Comment 1 Sergey V. Udaltsov 2010-10-03 07:47:40 UTC
These functions become of more importance since people are moving stuff to gsettings which have set_strv and get_strv functions.
Comment 2 Sergey V. Udaltsov 2010-10-04 10:11:16 UTC
Another useful one: "behead" - free first element and shift all pointers down.
Comment 3 Sergey V. Udaltsov 2010-10-04 10:14:37 UTC
Created attachment 171681 [details]
Minimal set of useful additions
Comment 4 Xavier Claessens 2012-10-10 12:22:57 UTC
I don't think we want to make GStrv modifiable, all the array resizing magic is already in GPtrArray:

GPtrArray *array;
GStrv strv;

array = g_ptr_array_sized_new (2);
g_ptr_array_add (array, g_strdup ("foo"));
g_ptr_array_add (array, g_strdup ("bar"));
...
g_ptr_array_add (array, NULL);
strv = g_ptr_array_free (array, FALSE);
Comment 5 Xavier Claessens 2012-10-10 12:56:02 UTC
I could help to have g_ptr_array_set_null_terminated() though. Like GArray's zero_terminated. Like that array->pdata is always a GStrv.
Comment 6 Xavier Claessens 2013-09-17 16:01:50 UTC
*** Bug 708250 has been marked as a duplicate of this bug. ***
Comment 7 Allison Karlitskaya (desrt) 2013-09-18 00:46:55 UTC
It's come up a few times that it may actually be useful to have a GPtrArray subset functionality specifically useful for strings (just as GPtrArray is a GArray for pointers).
Comment 8 Philip Withnall 2014-11-25 12:54:13 UTC
g_strv_contains() is implemented in bug #685880.
Comment 9 GNOME Infrastructure Team 2018-05-24 12:47:37 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/353.