[Asterisk-code-review] vector.h: Add AST_VECTOR_SORT() (asterisk[13])
Sean Bright
asteriskteam at digium.com
Mon Jul 20 14:23:23 CDT 2020
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/14687 )
Change subject: vector.h: Add AST_VECTOR_SORT()
......................................................................
vector.h: Add AST_VECTOR_SORT()
This allows a vector be sorted in-place, rather than only during
insertion.
Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780
---
M include/asterisk/vector.h
1 file changed, 10 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/14687/1
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 0e33590..1aa1611 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -358,6 +358,16 @@
})
/*!
+ * \brief Sort a vector in-place
+ *
+ * \param Vector to sort
+ * \param cmp A memcmp compatible compare function
+ */
+#define AST_VECTOR_SORT(vec, cmp) ({ \
+ qsort((vec)->elems, (vec)->current, sizeof(typeof((vec)->elems[0])), cmp); \
+})
+
+/*!
* \brief Remove an element from a vector by index.
*
* Note that elements in the vector may be reordered, so that the remove can
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14687
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I22cba9ddf556a7e44dacc53c4431bd81dd2fa780
Gerrit-Change-Number: 14687
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200720/fa288269/attachment.html>
More information about the asterisk-code-review
mailing list