jerenkrantz 2002/09/02 02:27:57
Modified: . CHANGES
include apr_tables.h
tables apr_tables.c
Log:
Add apr_array_pop() function to apr_array_header_t.
Revision Changes Path
1.328 +2 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.327
retrieving revision 1.328
diff -u -u -r1.327 -r1.328
--- CHANGES 1 Sep 2002 09:34:42 -0000 1.327
+++ CHANGES 2 Sep 2002 09:27:57 -0000 1.328
@@ -1,5 +1,7 @@
Changes with APR 0.9.0
+ *) Add apr_array_pop(). [Justin Erenkrantz]
+
*) Fixed the native SPARC v8plus version of apr_atomic_dec
to match the semantics of the default C version [Brian Pane]
1.34 +8 -0 apr/include/apr_tables.h
Index: apr_tables.h
===================================================================
RCS file: /home/cvs/apr/include/apr_tables.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -u -r1.33 -r1.34
--- apr_tables.h 13 Jul 2002 18:16:33 -0000 1.33
+++ apr_tables.h 2 Sep 2002 09:27:57 -0000 1.34
@@ -161,6 +161,14 @@
APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);
/**
+ * Remove an element from an array
+ * @param arr The array to remove an element from.
+ * @return Location of the element in the array.
+ * @remark If there are no elements in the array, NULL is returned.
+ */
+APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr);
+
+/**
* Concatenate two arrays together
* @param dst The destination array, and the one to go first in the combined
* array
1.43 +9 -0 apr/tables/apr_tables.c
Index: apr_tables.c
===================================================================
RCS file: /home/cvs/apr/tables/apr_tables.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -u -r1.42 -r1.43
--- apr_tables.c 29 Jul 2002 11:22:28 -0000 1.42
+++ apr_tables.c 2 Sep 2002 09:27:57 -0000 1.43
@@ -124,6 +124,15 @@
return res;
}
+APR_DECLARE(void *) apr_array_pop(apr_array_header_t *arr)
+{
+ if (apr_is_empty_array(arr)) {
+ return NULL;
+ }
+
+ return arr->elts + (arr->elt_size * (--arr->nelts));
+}
+
APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr)
{
if (arr->nelts == arr->nalloc) {