Preparation for CRC32 in index records - other changes required

Bron Gondwana brong at fastmail.fm
Tue Oct 23 23:01:26 EDT 2007


(Rob forgot to CC this everywhere)

On Wed, 24 Oct 2007 11:58:45 +1000, "Rob Mueller" <robm at fastmail.fm> said:
> 
> > mailbox_read_index_record(mailbox, msgno, &record);
> > record.uid
> > record.internaldate
> > record.size
> 
> structs are nice...
> 
> > int index_cache_record(struct mailbox *mailbox, unsigned msgno,
> >                       unsigned *size, char **records);
> 
> Could this be:
> 
> > int index_cache_record(struct mailbox *mailbox, unsigned msgno,
> >                       struct cache_records * cr);
> 
> And basically have:
> 
> struct cache_records {
>   char size;
>   char * start;
> 
>   char * env_to;
>   char * enc_cc;
>   ...
> };
> 
> Basically the same thing, but a bit less magic?


Yeah, OK.  I guess I can put the crc32 in there as well then.
At this point you may as well go the whole hog:

/* alignment issues - presumably everything here is 32bit on our architecture,
   but does it matter elsewhere or will they all go 64bit on a 64 bit machine? */
struct cache_record {
   char *base;
   unsigned size;
   ...
   char *env_to;
   unsigned env_to_len;
   char *env_cc;
   unsigned env_cc_len;
   ...
};

(singular struct name makes sense in the context)
   
The nice thing about this is you don't even need to read the
lengths off the front of each item before you use them, since
we already need to do that during the initial parse.  That way
the pointers are actually to the start of the string itself.

Bron.
-- 
  Bron Gondwana
  brong at fastmail.fm



More information about the Cyrus-devel mailing list