malloc()

Chris Torek chris at umcp-cs.UUCP
Sat May 24 14:11:17 AEST 1986


The real reason for `void *', which everyone seems to be missing,
is that it provides a generic pointer type.

Of course, if you need such a thing, you can usually get away with

	union all_possible_ptrs {
		char		*ifchar;
		unsigned char	*ifuchar;
		short		*ifshort;
		unsigned short	*ifushort;
		int		*ifint;
		unsigned int	*ifunit;
		long		*iflong;
		unsigned long	*ifulong;
		float		*iffloat;
		double		*ifdouble;
	};

but it is conceivable that this might be insufficent on a
machine with special structure pointers.  On such a machine,
this union might be (say) 30 bits wide, whereas a generic
pointer might be 34 bits.  Thus `void *'.

Besides, do you really *want* to use such a union?
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list