> I'll also give the code you posted a try.

Try this (boy, I'm enjoying this problem... ;)

        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;
        fieldp = field; // re-set the field pointer
        
        // 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;
        while ( i-- ) {
          q = fieldp++;
          while ( *p++ = *q++ );
        }

This is the tightest (and fastest) code that I can easily come up with.  This 
code should also easily become a function.  I'm definately going to be 
including this one in my projects.

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

 - "I drink to make other people interesting."
                -- George Jean Nathan


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

Reply via email to