I will assume you are referring to structure or pixel packing and define them for you.
Computers most quickly access numbers that are aligned according to their size.
For example, a short takes up 2 bytes, so you want it to be located on even addresses.
For numbers that don't even take up an integral amount of bytes (bit fields),
accessing them requires ANDing and SHIFTing words.
By default, C structures try to make accessing data easy by inserting space in between
structure elements so that each element can
be accessed as a byte, word, or long at the appropriate address. Some graphics modes
have pixels that take up 8, 16, or 32 bits, so
they too can be accessed easily. Also, in graphics, there may be padding at the end
of each scanline so each scan line starts on a
suitably aligned memory location.
For example:
struct { U8 ucChar; U16 sCount;}would normally take up 4 bytes of RAM because an 8-it
space would be inserted after ucChar so sCount
could start at an even memory location.
When structure elements or pixels (or even arrays) have padding to allow easy, quick
access, they are said to be "unpacked".
When instead, the bits of each field are rammed right up against each other with no
padding and must be extracted, especially if
there are bit fields, they are referred to as "packed." For example, in 4-bit
graphics mode, each byte has 2 pixels packed together
that must be extracted. If a struct is packed it means there are no spaces left
between structure members and it up to the
programmer to ensure proper alignment.
Dan Samber wrote:
> Just to show you that I have no shame, I will ask the ignorant question:
>
> Could someone please define the terms "packed" and "unpacked"?
>
> I seen them used many times and I probably have even made use
> of the distinction (by following code examples in books) but I don't
> know what these terms mean!
>
> Thanks
>
> Dan
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see
>http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/