if (pointer) command

Chris Torek chris at umcp-cs.UUCP
Mon Sep 8 10:46:17 AEST 1986


In article <1427 at ncoast.UUCP> allbery at 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 at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.unix mailing list