malloc() and sizeof

Andrew Koenig ark at alice.UUCP
Tue Apr 4 07:18:30 AEST 1989


I have found the following style useful:

	#define new(T) ((T *) malloc (sizeof (T)))

	struct Foo *fp = new(struct Foo);

This is, of course, reminiscent of C++.
-- 
				--Andrew Koenig
				  ark at europa.att.com



More information about the Comp.lang.c mailing list