mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 10:46:59 +00:00
shared/tests: add nmtst_rand_perm_strv() helper
This commit is contained in:
parent
826d4fd7a9
commit
8d6bd2f6c0
|
@ -1001,6 +1001,23 @@ nmtst_rand_perm(GRand *rand, void *dst, const void *src, gsize elmt_size, gsize
|
|||
return dst;
|
||||
}
|
||||
|
||||
static inline const char **
|
||||
nmtst_rand_perm_strv(const char *const *strv)
|
||||
{
|
||||
const char **res;
|
||||
gsize n;
|
||||
|
||||
if (!strv)
|
||||
return NULL;
|
||||
|
||||
/* this returns a (scrambled) SHALLOW copy of the strv array! */
|
||||
|
||||
n = NM_PTRARRAY_LEN(strv);
|
||||
res = (const char **) (nm_utils_strv_dup(strv, n, FALSE) ?: g_new0(char *, 1));
|
||||
nmtst_rand_perm(NULL, res, res, sizeof(char *), n);
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline GSList *
|
||||
nmtst_rand_perm_gslist(GRand *rand, GSList *list)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue