Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.programmer Subject: Re: free() in SAS C Message-ID: Date: 9 May 91 19:09:42 GMT References: <1991May02.143148.22732@edb.tih.no> Organization: Not an Organization Lines: 51 In article chopps@ro-chp.UUCP (Chris Hopps) writes: > >Just to be picky... yes malloc takes the type size_t as its only argument, but >size_t is of type unsigned int, thus on the amiga, if you are using 16 bit >ints the maximum is 65535 (64k) of course if you are using SAS/C defualt, int >is defined as 32 bit, which is a much larger number, something to be aware of >though. > >On this same point ANSI demands that type unsigned int's max value be at least >65535, but guarentees no more, thus if the strive is for portable code (why >else would you use malloc :^) ) then 64k is a good assumption. size_t is not necessarily an unsigned int, else they would have simply specified an unsigned int. size_t exists specifically so that 16 bit int compilers can typedef it to something *other* than an unsigned int. Frankly, in my opinion, any compiler that uses 16 bit ints for things like file seek positions, read()/write() size parameter, malloc(), and the like, are broken. Most IBM-PC compilers, such as TurboC, declare size_t is unsigned, i.e. 16 bit unsigned integer, and do exactly the above (except for seek positions). Of course, these compilers do not really support 32 bit ints well anyway, mainly because processors <386 don't really support 32 bit ints. For example, if you use a 32 bit integer as an index for an array, Turbo C will silently *IGNORE* the high 16 bits. Oops. I have found that I can declare 'short's in SAS/C and DICE and even though these are 32 bit int compilers, they do a pretty good job optimizing operations to stay within 16 bits when possible. If one is worried about efficiency and speed, one can use registered arguments which gets around basic differences in stacking (e.g. always stacking 32 bit arguments). The last time I used 16 bit integers was 5 years ago. >Chris... >-- > ------------------------ > The Royal Oak Chophouse Chris Hopps > Royal Oak, Michigan ....umich!wsu-cs!ro-chp!chopps > cs.wayne.edu!ro-chp!chopps -Matt -- Matthew Dillon dillon@Overload.Berkeley.CA.US 891 Regal Rd. uunet.uu.net!overload!dillon Berkeley, Ca. 94708 USA