Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mimsy!eneevax!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.UUCP Newsgroups: comp.lang.c,news.software.b Subject: Re: passing NULL to functions Message-ID: <5803@brl-smoke.ARPA> Date: Mon, 27-Apr-87 17:43:29 EDT Article-I.D.: brl-smok.5803 Posted: Mon Apr 27 17:43:29 1987 Date-Received: Wed, 29-Apr-87 01:13:52 EDT References: <150@sds.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 12 Xref: utgpu comp.lang.c:1866 news.software.b:537 In article <150@sds.UUCP> dave@sds.UUCP (dave schmidt x194) writes: >#define NIL(type) ((type)NULL) >#define ALLOC(type, qty) ((type *)calloc((qty), sizeof(type))) These are good; they explicitly address the important issue that the data type is an important factor. However, I would use malloc() rather than calloc(). It isn't clear what calloc()'s auto-filling with 0 should do; my interpretation is that it should fill with 0 "bytes" (usually the same as 0-valued (char)s), but that's not necessarily going to make any sense for floating-point or pointer data. It also adds overhead when one does one's own initialization of the allocated thingy. I think calloc() should be gotten rid of.