apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r233287 - /apr/apr/trunk/include/apr_tables.h
Date Thu, 18 Aug 2005 05:20:43 GMT
Author: rooneg
Date: Wed Aug 17 22:20:41 2005
New Revision: 233287

URL: http://svn.apache.org/viewcvs?rev=233287&view=rev
Log:
Add two helper macros for working with variable length arrays.

* include/apr_tables.h
  (APR_ARRAY_IDX, APR_ARRAY_PUSH): new macros.

Modified:
    apr/apr/trunk/include/apr_tables.h

Modified: apr/apr/trunk/include/apr_tables.h
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/include/apr_tables.h?rev=233287&r1=233286&r2=233287&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_tables.h (original)
+++ apr/apr/trunk/include/apr_tables.h Wed Aug 17 22:20:41 2005
@@ -120,6 +120,25 @@
  */
 APR_DECLARE(void *) apr_array_push(apr_array_header_t *arr);
 
+/** A helper macro for accessing a member of an APR array.
+ *
+ * @param ary the array
+ * @param i the index into the array to return
+ * @param type the type of the objects stored in the array
+ *
+ * @return the item at index i
+ */
+#define APR_ARRAY_IDX(ary,i,type) (((type *)(ary)->elts)[i])
+
+/** A helper macro for pushing elements into an APR array.
+ *
+ * @param ary the array
+ * @param type the type of the objects stored in the array
+ *
+ * @return the location where the new object should be placed
+ */
+#define APR_ARRAY_PUSH(ary,type) (*((type *)apr_array_push(ary)))
+
 /**
  * Remove an element from an array (as a first-in, last-out stack)
  * @param arr The array to remove an element from.



Mime
View raw message