Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Why does struct user_settings use ints when chars would do?
From: Björn Stenberg (bjorn_at_haxx.se)
Date: 2003-05-06


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örn



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa