Rockbox mail archiveSubject: Re: Why does struct user_settings use ints when chars would do?
Re: Why does struct user_settings use ints when chars would do?
From: Björn Stenberg <bjorn_at_haxx.se>
Date: Tue, 6 May 2003 08:53:54 +0200
TP Diffenbach wrote:
> So if these variables all hold values in the range of unsigned char
> (or less), why are they taking up sizeof( int ) bits?
Simply because the struct is a logical representation of the data, rather than a physical one. Numeric variables are thus stored in integers.
Using a consistent type also makes things like set_integer() possible.
We waste perhaps 100 bytes for data, but gain them back in simpler code.
-- BjörnReceived on 2003-05-06