+ oldstrings = list->strings;
+ list->maxstrings += 4096;
+ list->strings = (char **) Z_Malloc(list->maxstrings * sizeof(*list->strings));
+ if (list->numstrings)
+ memcpy(list->strings, oldstrings, list->numstrings * sizeof(*list->strings));
+ if (oldstrings)
+ Z_Free(oldstrings);
+ }
+ textlen = strlen(text) + 1;
+ list->strings[list->numstrings] = (char *) Z_Malloc(textlen);
+ memcpy(list->strings[list->numstrings], text, textlen);
+ list->numstrings++;
+}
+
+static int stringlistsort_cmp(const void *a, const void *b)
+{
+ return strcasecmp(*(const char **)a, *(const char **)b);
+}
+
+void stringlistsort(stringlist_t *list, qboolean uniq)
+{
+ int i, j;
+ if(list->numstrings < 1)
+ return;
+ qsort(&list->strings[0], list->numstrings, sizeof(list->strings[0]), stringlistsort_cmp);
+ if(uniq)
+ {
+ // i: the item to read
+ // j: the item last written
+ for (i = 1, j = 0; i < list->numstrings; ++i)