summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ef6ca1)
raw | patch | inline | side by side (parent: 7ef6ca1)
author | Florian Forster <ff@octo.it> | |
Mon, 21 Jun 2010 08:39:32 +0000 (10:39 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 21 Jun 2010 08:39:32 +0000 (10:39 +0200) |
src/utils_array.c | patch | blob | history | |
src/utils_array.h | patch | blob | history |
diff --git a/src/utils_array.c b/src/utils_array.c
index 5aaabbc5c1d35d38e96ffef8af099775f7a0ed32..e7ac51e784fe9aaa5def1b5fac5fe2c6e0dd70fc 100644 (file)
--- a/src/utils_array.c
+++ b/src/utils_array.c
size_t size;
};
+static int sort_callback (const void *v0, const void *v1) /* {{{ */
+{
+ const char *c0 = v0;
+ const char *c1 = v1;
+
+ return (strcmp (c0, c1));
+} /* }}} int sort_callback */
+
str_array_t *array_create (void) /* {{{ */
{
str_array_t *a;
return (array_append (a, buffer));
} /* }}} int array_append_format */
+int array_sort (str_array_t *a) /* {{{ */
+{
+ if (a == NULL)
+ return (EINVAL);
+
+ qsort (a->ptr, a->size, sizeof (*a->ptr), sort_callback);
+
+ return (0);
+} /* }}} int array_sort */
+
int array_argc (str_array_t *a) /* {{{ */
{
if (a == NULL)
diff --git a/src/utils_array.h b/src/utils_array.h
index 917bea95e9cee0b142b2809cf1e059f416e7b63c..141dbaa48fdd2ca432cb5ee0459c05c09e61a0c5 100644 (file)
--- a/src/utils_array.h
+++ b/src/utils_array.h
int array_append_format (str_array_t *a, const char *format, ...)
__attribute__((format(printf,2,3)));
+int array_sort (str_array_t *a);
+
int array_argc (str_array_t *);
char **array_argv (str_array_t *);