Add uc_strv_reverse

This commit is contained in:
Nils O. Selåsdal
2015-12-10 19:13:16 +01:00
parent 9b70b64729
commit db78689015
3 changed files with 55 additions and 0 deletions
+11
View File
@@ -130,3 +130,14 @@ int uc_strv_append_all(struct UCStrv *restrict a, struct UCStrv *restrict b, int
return 0;
}
void uc_strv_reverse(struct UCStrv *strv)
{
for (size_t i = 0; i < strv->cnt / 2; i++) {
size_t k = strv->cnt - i - 1;
char *tmp = strv->strings[i];
strv->strings[i] = strv->strings[k];
strv->strings[k] = tmp;
}
}