Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 69311 invoked from network); 12 Dec 2003 18:07:38 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Dec 2003 18:07:38 -0000 Received: (qmail 72058 invoked by uid 500); 12 Dec 2003 18:07:19 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 72015 invoked by uid 500); 12 Dec 2003 18:07:18 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 71942 invoked from network); 12 Dec 2003 18:07:18 -0000 Subject: [PATCH] Convenience macros for apr array manipulation From: Sander Striker To: dev@apr.apache.org Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Striker Solutions Message-Id: <1071252440.1568.7093.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Fri, 12 Dec 2003 19:07:20 +0100 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi, We've been using macros similar to these in Subversion for a while (courtesy of Mike Pilato). It saves users from (mis)typing the regular syntax. Comments? Sander > Index: apr_tables.h > =================================================================== > RCS file: /home/cvs/apr/include/apr_tables.h,v > retrieving revision 1.38 > diff -u -r1.38 apr_tables.h > --- apr_tables.h 22 Jun 2003 21:50:25 -0000 1.38 > +++ apr_tables.h 12 Dec 2003 17:53:30 -0000 > @@ -224,6 +224,23 @@ > const char sep); > > /** > + * Push a new item of a certain type into an array. > + * @param arr The array to add the item to > + * @param type Type of the item > + * @param item The item to add > + */ > +#define APR_ARRAY_PUSH(arr, type, item) \ > + (*((type *)apr_array_push(arr))) = (item) > + > +/** > + * Get an item at a specified index in an array > + * @param arr The array to get the item from > + * @param idx The index into the array > + * @param type The type of the item > + */ > +#define APR_ARRAY_IDX(arr, idx, type) (((type *)(arr)->elts)[idx]) > + > +/** > * Make a new table > * @param p The pool to allocate the pool out of > * @param nelts The number of elements in the initial table.