2005-03-14 Paul Jakma <paul.jakma@sun.com>
* (global) update all c files to match the lib/vector.h rename of
(struct vector).active to max, and vector_max macro to
vector_active.
* lib/vector.h: Rename to (struct vector).max to slightly less
confusing active, for the number of active slots, distinct from
allocated or active-and-not-empty. Rename vector_max to
vector_active for same reason.
diff --git a/lib/vector.h b/lib/vector.h
index 7e00c39..deaf6a8 100644
--- a/lib/vector.h
+++ b/lib/vector.h
@@ -26,7 +26,7 @@
/* struct for vector */
struct _vector
{
- unsigned int max; /* max number of used slot */
+ unsigned int active; /* number of active slots */
unsigned int alloced; /* number of allocated slot */
void **index; /* index to data */
};
@@ -36,8 +36,13 @@
/* (Sometimes) usefull macros. This macro convert index expression to
array expression. */
+/* Reference slot at given index, caller must ensure slot is active */
#define vector_slot(V,I) ((V)->index[(I)])
-#define vector_max(V) ((V)->max)
+/* Number of active slots.
+ * Note that this differs from vector_count() as it the count returned
+ * will include any empty slots
+ */
+#define vector_active(V) ((V)->active)
/* Prototypes. */
vector vector_init (unsigned int size);