On Sat, 16 Dec 2006, Martin Peach wrote:
Yes, and it's also easier to limit strings to word (16-bit) lengths, while 8-bit is too short. So a t_string would look like: typedef struct _string /* pointer to a string */ { unsigned short s_length; /* length of string in bytes */ unsigned char *s_data; /* pointer to 1st byte of string */ } t_string;
If you're not compiling in 16-bit mode, then there will be 2 or 6 bytes between the first and second field, so that the second field can be aligned to a word boundary, supposing that the struct as a whole is itself aligned to a word boundary. (By word, I strictly mean something that is the same size as a pointer.)
What I mean is that it's useless to not use the whole a length field that is not the same size as the pointer field, if you have only those two fields. If you have more than two fields, then you can put several short fields in the space of a word (2 or 4).
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada