r5596 jmb - in /trunk/libparserutils: include/parserutils/utils/vector.h src/utils/vector.c

netsurf at semichrome.net netsurf at semichrome.net
Sat Oct 18 16:18:43 BST 2008


Author: jmb
Date: Sat Oct 18 10:18:43 2008
New Revision: 5596

URL: http://source.netsurf-browser.org?rev=5596&view=rev
Log:
Add API to vector to permit peeking.

Modified:
    trunk/libparserutils/include/parserutils/utils/vector.h
    trunk/libparserutils/src/utils/vector.c

Modified: trunk/libparserutils/include/parserutils/utils/vector.h
URL: http://source.netsurf-browser.org/trunk/libparserutils/include/parserutils/utils/vector.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libparserutils/include/parserutils/utils/vector.h (original)
+++ trunk/libparserutils/include/parserutils/utils/vector.h Sat Oct 18 10:18:43 2008
@@ -27,6 +27,8 @@
 
 const void *parserutils_vector_iterate(const parserutils_vector *vector, 
 		int32_t *ctx);
+const void *parserutils_vector_peek(const parserutils_vector *vector,
+		int32_t ctx);
 
 #endif
 

Modified: trunk/libparserutils/src/utils/vector.c
URL: http://source.netsurf-browser.org/trunk/libparserutils/src/utils/vector.c?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libparserutils/src/utils/vector.c (original)
+++ trunk/libparserutils/src/utils/vector.c Sat Oct 18 10:18:43 2008
@@ -179,6 +179,26 @@
 	return item;
 }
 
+/**
+ * Peek at an item in a vector
+ *
+ * \param vector  The vector to iterate over
+ * \param ctx     Integer for the iterator to use as context.
+ * \return Pointer to item, or NULL if no more
+ */
+const void *parserutils_vector_peek(const parserutils_vector *vector, 
+		int32_t ctx)
+{
+	if (vector == NULL || vector->current_item < 0)
+		return NULL;
+
+	if (ctx > vector->current_item)
+		return NULL;
+
+	return (uint8_t *) vector->items + (ctx * vector->item_size);
+}
+
+
 #ifndef NDEBUG
 #include <stdio.h>
 




More information about the netsurf-commits mailing list