Arg.  It's late, I'm tired, and I made some silly mistakes in that... namely 
dereferencing some pointers, and fixing a compiler warning.  So here's the 
-real- code (I think, there may still be issues in it):

        Char *p, *q;
        Char *packed;
        Char *field[NUM_FIELDS];
        Char *fieldp = field;
        UInt32 packed_size = 0;
        UInt16 i;

        // First pass, find the packed size of the strings.
        i = NUM_FIELDS;
        while ( i-- ) packed_size += StrLen(*fieldp++) + 1;

        // Allocate enough space for the packed strings.
        packed = (Char *)MemPtrNew(sizeof(Char) * packed_size);
        p = packed;

        // Now, copy the strings.  This looks crufty, but makes sense.
        i = NUM_FIELDS;
        fieldp = field; // re-set the field pointer
        while ( i-- ) {
          q = *fieldp++;
          while ( (*p++ = *q++) );
        }

-- 
Matthew (Darkstorm) Bevan       [EMAIL PROTECTED]
Margin Software, NECTI.         http://www.marginsoftware.com
        Re-inventing the wheel, every time.

 - Madam, there's no such thing as a tough child -- if you parboil them
first for seven hours, they always come out tender.
                -- W. C. Fields


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to