strcpy

Mark Brader msb at sq.uucp
Fri Apr 1 09:33:21 AEST 1988


Regarding:
> > If a machine has a fast instruction that
> > does a search for a byte and a fast block move instruction, it would
> > probably be best for strcpy to be written
> > 
> > 	memcpy (dest, src, strpos (src, '\0') + 1);
> > 
> > (assuming that memcpy and strpos are inlined into the appropriate
> > instructions ... )

I said, in an article I am now canceling:
> The above
> algorithm is two-pass, and therefore not robust in the face 
> of *shared memory*.

It has been pointed out to me that a one-pass algorithm is also not
robust in a shared-memory situation.  The two-pass and one-pass
algorithms merely fail in slightly different ways and on slightly
different race conditions.

Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb at sq.com
	"I'm a little worried about the bug-eater," she said.  "We're embedded
	in bugs, have you noticed?"		-- Niven, "The Integral Trees"



More information about the Comp.lang.c mailing list