Quick note re:

> 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).

That's not the definition of size_t. The delta of
two pointers you're referring to is ptrdiff_t.

size_t is an unsigned integral type that holds the value
of a sizeof operation. The relationship you mention
need not be true on a 64-bit platform.

---Andrew Binstock

>>> re >>>

At 12:41 AM 5/18/2005, William A. Rowe, Jr. wrote:

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);


Pacific Data Works LLC
Technology White Papers
www.pacificdataworks.com