🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #276

Re: size_t

#276
From: Tapani Tarvainen
Date: Tue, 20 Jun 1989 06:12
33 lines
1685 bytes
In article <845@cbnewsl.ATT.COM> dfp@cbnewsl.ATT.COM (david.f.prosser) writes:
>Section 4.1.5 of the pANS:
>
>	The types [defined in <stddef.h>] are ...
>
>		size_t
>
>	which is the unsigned integral type of the result of the sizeof
>	operator ...
>
>It is also defined in <stdio.h>, <stdlib.h>, <string.h> and <time.h>.

If this is all pANS says about it, TurboC's behaviour is legal.
As static objects can't exceed 64K, sizeof result will always
fit in unsigned int; but in huge model one can have a dynamic
array with more than 64K elements.  Therefore:

What should be done when one has an array whose indices may not fit
in an int?  Is there a suitable type for that in pANS?

If I use long, TC will warn that "Conversion may lose significant digits"
every time in models other than huge, not to mention that it is waste
of resources, but in huge model int won't do.
Suggestions, anyone?

(BTW, thank you David for informative answers, even though the info on
realloc was somewhat unfortunate: it seems I'll need an extra variable
for every pointer to the buffer that is reallocated.)


-- 
Tapani Tarvainen                 BitNet:    tarvainen@finjyu
Internet:  tarvainen@jylk.jyu.fi  -- OR --  tarvaine@tukki.jyu.fi
Technical Details
Message-ID: <941@tukki.jyu.fi>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!kth!draken!tut!tukki!tarvaine
References: <934@tukki.jyu.fi> <845@cbnewsl.ATT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!kth!draken!tut!tukki!tarvaine
From: tarvaine@tukki.jyu.fi (Tapani Tarvainen)
Newsgroups: comp.std.c
Subject: Re: size_t
Message-ID: <941@tukki.jyu.fi>
Date: 20 Jun 89 06:12:54 GMT
References: <934@tukki.jyu.fi> <845@cbnewsl.ATT.COM>
Reply-To: tarvaine@tukki.jyu.fi (Tapani Tarvainen)
Organization: University of Jyvaskyla, Finland
Lines: 33