Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix Subject: Re: if (pointer) command Message-ID: <3304@umcp-cs.UUCP> Date: Sun, 7-Sep-86 20:46:17 EDT Article-I.D.: umcp-cs.3304 Posted: Sun Sep 7 20:46:17 1986 Date-Received: Sun, 7-Sep-86 22:55:36 EDT References: <3325@brl-smoke.ARPA> <241@bsdpkh.UUCP> <1170@ttrdc.UUCP> <1427@ncoast.UUCP> Reply-To: chris@umcp-cs.UUCP (Chris Torek) Organization: University of Maryland, Dept. of Computer Sci. Lines: 19 In article <1427@ncoast.UUCP> allbery@ncoast.UUCP (Brandon Allbery) writes: [re the following (edited) code:] char *strdup(s) char *s; { char *p, *malloc(); if(p=malloc(strlen(s)+1)) strcpy(p,s); return p; } >But if a pointer is 4 bits [sic] and an int is 2 bits (some 68000 >implementations), you'll get spurious failures if the pointer returned >by malloc is a multiple of 0x10000! No: the test `if (p)' compares p with zero, and in this context the zero is coerced to a (char *)0. That the zero is only implied is unimportant. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu