summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2019-02-26 19:48:41 +0300
committerIgor Sysoev <igor@sysoev.ru>2019-02-26 19:48:41 +0300
commitce650ea0f703f9228638e88ccb62d207aa647bf2 (patch)
treeed54eed3f54aba96497a626706fd5c34e3a7f748
parent547082171e5e78561964e0e64e16a47a5f9d92df (diff)
downloadunit-ce650ea0f703f9228638e88ccb62d207aa647bf2.tar.gz
unit-ce650ea0f703f9228638e88ccb62d207aa647bf2.tar.bz2
Introduced nxt_conf_array_qsort().
-rw-r--r--src/nxt_conf.c16
-rw-r--r--src/nxt_conf.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c
index f69133cc..4c6d8839 100644
--- a/src/nxt_conf.c
+++ b/src/nxt_conf.c
@@ -720,6 +720,22 @@ nxt_conf_get_array_element(nxt_conf_value_t *value, uint32_t index)
}
+void
+nxt_conf_array_qsort(nxt_conf_value_t *value,
+ int (*compare)(const void *, const void *))
+{
+ nxt_conf_array_t *array;
+
+ if (value->type != NXT_CONF_VALUE_ARRAY) {
+ return;
+ }
+
+ array = value->u.array;
+
+ nxt_qsort(array->elements, array->count, sizeof(nxt_conf_value_t), compare);
+}
+
+
nxt_int_t
nxt_conf_op_compile(nxt_mp_t *mp, nxt_conf_op_t **ops, nxt_conf_value_t *root,
nxt_str_t *path, nxt_conf_value_t *value)
diff --git a/src/nxt_conf.h b/src/nxt_conf.h
index 7c360dfe..052334fe 100644
--- a/src/nxt_conf.h
+++ b/src/nxt_conf.h
@@ -126,6 +126,8 @@ void nxt_conf_set_element(nxt_conf_value_t *array, nxt_uint_t index,
nxt_int_t nxt_conf_set_element_string_dup(nxt_conf_value_t *array, nxt_mp_t *mp,
nxt_uint_t index, nxt_str_t *value);
nxt_uint_t nxt_conf_array_elements_count(nxt_conf_value_t *value);
+void nxt_conf_array_qsort(nxt_conf_value_t *value,
+ int (*compare)(const void *, const void *));
#endif /* _NXT_CONF_INCLUDED_ */