Go Back   Velocity Reviews > Newsgroups > C Programming
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

C Programming - The problem with size_t

 
Thread Tools Search this Thread
Old 10-15-2009, 10:41 AM   #1
Default The problem with size_t


I am implementing the bitstring type in the container library, and
obviously I store the number of bits in a size_t...

Problem is, in 64 bit versions, size_t grows to 8 bytes, what
is an absolute overkill for a number that in most cases will
fit in 16 bits, or, at most 32.

And this happens in all containers. I do not see most applications
use containers with more than 4G elements... In a 64 bit system
size_t is just too much waste.

Now I see the problems Malcom was pointing at when he ranted at size_t.

What would be the alternatives?

uin32_t?

That one looks better. Any problem with that?


jacob navia
  Reply With Quote
Old 10-15-2009, 11:57 AM   #2
Nick Keighley
 
Posts: n/a
Default Re: The problem with size_t
On 15 Oct, 10:41, jacob navia <ja...@nospam.org> wrote:

> I am implementing the bitstring type in the container library, and
> obviously I store the number of bits in a size_t...


obviously...

> Problem is, in 64 bit versions, size_t grows to 8 bytes, what
> is an absolute overkill for a number that in most cases will
> fit in 16 bits, or, at most 32.
>
> And this happens in all containers. I do not see most applications
> use containers with more than 4G elements...


if you don't want containers with more than 4G elements why are you
using a
64-bit system?

> In a 64 bit system size_t is just too much waste.
>
> Now I see the problems Malcom was pointing at when he ranted at size_t.


I always thought his rant was a bit odd

> What would be the alternatives?
>
> uin32_t?
>
> That one looks better. Any problem with that?


it won't hold more than 4G elements!




Nick Keighley
  Reply With Quote
Old 10-15-2009, 12:12 PM   #3
Noob
 
Posts: n/a
Default Re: The problem with size_t
jacob navia wrote:

> [...] size_t grows to 8 bytes, what is an absolute overkill [...]


<OT grammar nit>
In this context, one would write "which" not "what".
(English native speakers: is my statement correct?)
I've seen several francophone posters make this mistake.
Is this grammatical rule incorrectly taught in school, perhaps?
</OT>


Noob
  Reply With Quote
Old 10-15-2009, 01:43 PM   #4
Nick Keighley
 
Posts: n/a
Default Re: The problem with size_t
On 15 Oct, 12:12, Noob <r...@127.0.0.1> wrote:
> jacob navia wrote:


> > [...] size_t grows to 8 bytes, what is an absolute overkill [...]

>
> <OT grammar nit>
> In this context, one would write "which" not "what".
> (English native speakers: is my statement correct?)


yes

> I've seen several francophone posters make this mistake.
> Is this grammatical rule incorrectly taught in school, perhaps?
> </OT>




Nick Keighley
  Reply With Quote
Old 10-15-2009, 02:52 PM   #5
Dik T. Winter
 
Posts: n/a
Default Re: The problem with size_t
In article <hb7032$o2$> Noob <root@127.0.0.1> writes:
> jacob navia wrote:
>
> > [...] size_t grows to 8 bytes, what is an absolute overkill [...]

>
> <OT grammar nit>
> In this context, one would write "which" not "what".
> (English native speakers: is my statement correct?)
> I've seen several francophone posters make this mistake.
> Is this grammatical rule incorrectly taught in school, perhaps?
> </OT>


In French (as in Dutch) which translates in this position to a word that
is also a translation of what. So when you use the translated word in
your native language you have to think about the difference in meaning
when translating into English.

Similar to "teach" and "learn" that can be (and frequently will be)
translated to the same word in Dutch.
--
dik t. winter, cwi, science park 123, 1098 xg amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/


Dik T. Winter
  Reply With Quote
Old 10-15-2009, 03:17 PM   #6
Ben Bacarisse
 
Posts: n/a
Default Re: The problem with size_t
jacob navia <> writes:

> I am implementing the bitstring type in the container library, and
> obviously I store the number of bits in a size_t...
>
> Problem is, in 64 bit versions, size_t grows to 8 bytes, what
> is an absolute overkill for a number that in most cases will
> fit in 16 bits, or, at most 32.


I can't see why bitstrings
>
> And this happens in all containers. I do not see most applications
> use containers with more than 4G elements... In a 64 bit system
> size_t is just too much waste.
>
> Now I see the problems Malcom was pointing at when he ranted at size_t.
>
> What would be the alternatives?
>
> uin32_t?
>
> That one looks better. Any problem with that?


--
Ben.


Ben Bacarisse
  Reply With Quote
Old 10-15-2009, 03:19 PM   #7
Joachim Schmitz
 
Posts: n/a
Default Re: The problem with size_t
Dik T. Winter wrote:
> In article <hb7032$o2$> Noob <root@127.0.0.1> writes:
>> jacob navia wrote:
>>
>>> [...] size_t grows to 8 bytes, what is an absolute overkill [...]

>>
>> <OT grammar nit>
>> In this context, one would write "which" not "what".
>> (English native speakers: is my statement correct?)
>> I've seen several francophone posters make this mistake.
>> Is this grammatical rule incorrectly taught in school, perhaps?
>> </OT>

>
> In French (as in Dutch) which translates in this position to a word
> that is also a translation of what. So when you use the translated
> word in your native language you have to think about the difference
> in meaning when translating into English.


Same in German.

> Similar to "teach" and "learn" that can be (and frequently will be)
> translated to the same word in Dutch.


Happens in German too, but is utterly wrong. "teach" is "lehren", "lern" is
"lernen".
Quite a few Germans don't care and use "lernen" in either case.

Bye, Jojo



Joachim Schmitz
  Reply With Quote
Old 10-15-2009, 03:25 PM   #8
Ben Bacarisse
 
Posts: n/a
Default Re: The problem with size_t
[I cancelled a previous reply sent unfinished (hardly begun!) but I
image it will get though. Please ignore it.]

jacob navia <> writes:

> I am implementing the bitstring type in the container library, and
> obviously I store the number of bits in a size_t...
>
> Problem is, in 64 bit versions, size_t grows to 8 bytes, what
> is an absolute overkill for a number that in most cases will
> fit in 16 bits, or, at most 32.
>
> And this happens in all containers. I do not see most applications
> use containers with more than 4G elements... In a 64 bit system
> size_t is just too much waste.


If the implementation has decided that size_t should be 64 bits, then
I'd want containers that can be that large. I don't see that as a
problem but I don't use ever use low-memory systems with 64-bit
size_t. It soulds like you are worrying about a corner case.

> Now I see the problems Malcom was pointing at when he ranted at
> size_t.


I though he objected to not using int and wanted int, on all systems,
to be 64 bits? That would have a much higher memory impact the not
using size_t.

<snip>
--
Ben.


Ben Bacarisse
  Reply With Quote
Old 10-15-2009, 03:40 PM   #9
Dik T. Winter
 
Posts: n/a
Default Re: The problem with size_t
In article <hb7b29$u9e$> "Joachim Schmitz" <> writes:
> Dik T. Winter wrote:

....
> > Similar to "teach" and "learn" that can be (and frequently will be)
> > translated to the same word in Dutch.

>
> Happens in German too, but is utterly wrong. "teach" is "lehren", "lern" is
> "lernen".


But in Dutch it is correct. "leren" has two meanings, transitive and
intransitive, which makes a sentence like:
De man leert pianospelen
ambiguous (the man teaches/learns playing piano).
--
dik t. winter, cwi, science park 123, 1098 xg amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/


Dik T. Winter
  Reply With Quote
Old 10-15-2009, 03:54 PM   #10
Joachim Schmitz
 
Posts: n/a
Default Re: The problem with size_t
Dik T. Winter wrote:
> In article <hb7b29$u9e$> "Joachim Schmitz"
> <> writes:
>> Dik T. Winter wrote:

> ...
>>> Similar to "teach" and "learn" that can be (and frequently will be)
>>> translated to the same word in Dutch.

>>
>> Happens in German too, but is utterly wrong. "teach" is "lehren",
>> "lern" is "lernen".

>
> But in Dutch it is correct. "leren" has two meanings, transitive and
> intransitive, which makes a sentence like:
> De man leert pianospelen
> ambiguous (the man teaches/learns playing piano).


OK, then I now know where that mistake stems from (living so 60km from the
Dutch border

Bye, Jojo



Joachim Schmitz
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comcast + Wireless Internet Problem shadoweloc General Help Related Topics 1 07-01-2008 06:19 PM
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46