At 09:01 AM 5/17/2005, Joe Orton wrote: >On Mon, May 16, 2005 at 01:39:20PM -0500, William Rowe wrote: >> Issue #1; How to manipulate nelts in apr_table_entry? >> >> We can preserve the existing behavior of nelts, defining it as >> a simple int. A few casts are required out of the result of some >> pointer arithmetic. > >Can you explain what casts are needed exactly, and why? It's embodied by the patch below - the delta of two pointer offsets result in a size_t (by definition). On LP64/P64, the sizeof(int) < sizeof(size_t). Author: wrowe Date: Mon May 16 14:49:49 2005 New Revision: 170468 URL: http://svn.apache.org/viewcvs?rev=170468&view=rev Log: We play pointer math with local 'i', so it must be apr_size_t. Until we decide otherwise, cast the pointer math result back to an int for a nelts result. Modified: apr/apr/trunk/tables/apr_tables.c Modified: apr/apr/trunk/tables/apr_tables.c URL: http://svn.apache.org/viewcvs/apr/apr/trunk/tables/apr_tables.c?rev=170468&r1=170467&r2=170468&view=diff ============================================================================== --- apr/apr/trunk/tables/apr_tables.c (original) +++ apr/apr/trunk/tables/apr_tables.c Mon May 16 14:49:49 2005 @@ -970,7 +970,7 @@ */ apr_table_entry_t **values_tmp = (apr_table_entry_t **)apr_palloc(pool, n * sizeof(apr_table_entry_t*)); - int i; + apr_size_t i; int blocksize; /* First pass: sort pairs of elements (blocksize=1) */ @@ -1156,7 +1156,7 @@ *dst++ = *src; } } while (++src < last_elt); - t->a.nelts -= (last_elt - dst); + t->a.nelts -= (int)(last_elt - dst); } table_reindex(t);