FAQ - malloc array - clarify

Chris Torek chris at mimsy.umd.edu
Wed Sep 12 16:43:16 AEST 1990


In article <1806 at tuvie> hp at vmars.tuwien.ac.at (Peter Holzer) writes:
[part of an aside:]
>The lint libraries are ASCII files on our system. Are they in a compiled 
>form on yours ?

Yes; they are built from ASCII files which are also installed.  The
situation differs under some versions of System V.

>In <sys/types.h>:
>	typedef int size_t;	/* returned by sizeof */
>				/* this is a compiler bug.
>				   should be unsigned	*/

The `size_t' you find in <sys/types.h> is *NOT* the `size_t' meant by
ANSI C.  <sys/types.h>'s `size_t' is the `size of a text, data, or
stack segment in clicks', not the `size of a contiguous memory block
in bytes'.  They merely (unfortunately) happen to have the same name.

In 4.3BSD-reno, the `size_t' in <sys/types.h> has been renamed `segsz_t'
and a proper (unsigned) size_t is defined in the proper ANSI <std*.h>
files.

One can fix this on binary-only Unix systems by changing that one line
in <sys/types.h> to read

	typedef int segsz_t;
	#ifdef KERNEL
	#define size_t segsz_t
	#endif

Unfortunately, you have to remember to reinstall this change with every
system upgrade until your vendor catches on.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list