diff options
| author | Michael Biebl <biebl@debian.org> | 2017-01-23 23:34:56 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-01-23 23:34:56 +0100 |
| commit | d462f64d6044349b0a4e3581cf2c97bbab7aec97 (patch) | |
| tree | 0743acb1a191ce83b5722d77aeb896c6c0cdd952 /shared/nm-utils | |
| parent | 58f8be580039b0575b197b9573a1c92745d96d30 (diff) | |
New upstream version 1.5.91 upstream/1.5.91
Diffstat (limited to 'shared/nm-utils')
| -rw-r--r-- | shared/nm-utils/nm-test-utils.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h index 7e712dcd..7be7e254 100644 --- a/shared/nm-utils/nm-test-utils.h +++ b/shared/nm-utils/nm-test-utils.h @@ -832,6 +832,31 @@ nmtst_rand_perm (GRand *rand, void *dst, const void *src, gsize elmt_size, gsize return dst; } +inline static GSList * +nmtst_rand_perm_gslist (GRand *rand, GSList *list) +{ + GSList *result; + guint l; + + if (!rand) + rand = nmtst_get_rand (); + + /* no need for an efficient implementation :) */ + + result = 0; + for (l = g_slist_length (list); l > 0; l--) { + GSList *tmp; + + tmp = g_slist_nth (list, g_rand_int (rand) % l); + g_assert (tmp); + + list = g_slist_remove_link (list, tmp); + result = g_slist_concat (tmp, result); + } + g_assert (!list); + return result; +} + /*****************************************************************************/ inline static gboolean |