summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-11-13 17:26:22 -0600
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-11-13 17:26:23 -0600
commit8ae31f712669da8f7bb52fd360afca33752064da (patch)
treeb6426884a0871b72a55088777432713b11da63b0
parent52c1d052962abd89709159333eb420190c255ad5 (diff)
parent4930404715bcdaad43d9b8e53df16d6323c49979 (diff)
Merge "vectors: Add new macro and a string vector definition."
-rw-r--r--include/asterisk/vector.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 68ce13065..8bd1cefef 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -51,6 +51,9 @@
/*! \brief Integer vector definition */
AST_VECTOR(ast_vector_int, int);
+/*! \brief String vector definition */
+AST_VECTOR(ast_vector_string, char *);
+
/*!
* \brief Define a vector structure with a read/write lock
*
@@ -91,6 +94,26 @@ AST_VECTOR(ast_vector_int, int);
})
/*!
+ * \brief Steal the elements from a vector and reinitialize.
+ *
+ * \param vec Vector to operate on.
+ *
+ * This allows you to use vector.h to construct a list and use the
+ * data as a bare array.
+ *
+ * \note The stolen array must eventually be released using ast_free.
+ *
+ * \warning AST_VECTOR_SIZE and AST_VECTOR_MAX_SIZE are both reset
+ * to 0. If either are needed they must be saved to a local
+ * variable before stealing the elements.
+ */
+#define AST_VECTOR_STEAL_ELEMENTS(vec) ({ \
+ typeof((vec)->elems) __elems = (vec)->elems; \
+ AST_VECTOR_INIT((vec), 0); \
+ (__elems); \
+})
+
+/*!
* \brief Initialize a vector with a read/write lock
*
* If \a size is 0, then no space will be allocated until the vector is