summaryrefslogtreecommitdiff
path: root/src/utils/vector.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-15 12:09:03 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-15 12:09:03 +0000
commitac294568caf6b7c4572a62809be531a117108e8b (patch)
treeb04d2761c699186b72942b4e122d8a5f6b238e0b /src/utils/vector.c
parentbf44aeaf5cd7f03d3bd842c8046b7346c5035f06 (diff)
downloadlibparserutils-ac294568caf6b7c4572a62809be531a117108e8b.tar.gz
libparserutils-ac294568caf6b7c4572a62809be531a117108e8b.tar.bz2
Add ability to retrieve vector length. Fix missing note in iteration api
svn path=/trunk/libparserutils/; revision=6527
Diffstat (limited to 'src/utils/vector.c')
-rw-r--r--src/utils/vector.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/utils/vector.c b/src/utils/vector.c
index 2571ba4..ab895e3 100644
--- a/src/utils/vector.c
+++ b/src/utils/vector.c
@@ -165,11 +165,34 @@ parserutils_error parserutils_vector_remove_last(parserutils_vector *vector)
}
/**
+ * Acquire the length (in items) of the vector.
+ *
+ * \param vector The vector to interrogate.
+ * \param length Pointer to location to receive length information.
+ * \return PARSERUTILS_OK on success, appropriate error otherwise
+ */
+parserutils_error parserutils_vector_get_length(parserutils_vector *vector,
+ size_t *length)
+{
+ if (vector == NULL)
+ return PARSERUTILS_BADPARM;
+
+ if (length == NULL)
+ return PARSERUTILS_BADPARM;
+
+ *length = vector->current_item + 1;
+
+ return PARSERUTILS_OK;
+}
+
+/**
* Iterate over a vector
*
* \param vector The vector to iterate over
* \param ctx Pointer to an integer for the iterator to use as context.
* \return Pointer to current item, or NULL if no more
+ *
+ * \note The value pointed to by \a ctx must be zero to begin the iteration.
*/
const void *parserutils_vector_iterate(const parserutils_vector *vector,
int32_t *ctx)