mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 05:13:06 +02:00
Merge branch 'strsplit-pre-allocated-array' into 'main'
g_strsplit: Use a pre-allocated GArray when max_tokens is provided See merge request GNOME/glib!2875
This commit is contained in:
commit
1a32433f31
@ -2425,9 +2425,15 @@ g_strsplit (const gchar *string,
|
||||
g_return_val_if_fail (delimiter[0] != '\0', NULL);
|
||||
|
||||
if (max_tokens < 1)
|
||||
max_tokens = G_MAXINT;
|
||||
{
|
||||
max_tokens = G_MAXINT;
|
||||
string_list = g_ptr_array_new ();
|
||||
}
|
||||
else
|
||||
{
|
||||
string_list = g_ptr_array_new_full (max_tokens + 1, NULL);
|
||||
}
|
||||
|
||||
string_list = g_ptr_array_new ();
|
||||
remainder = string;
|
||||
s = strstr (remainder, delimiter);
|
||||
if (s)
|
||||
|
Loading…
x
Reference in New Issue
Block a user