Date: Wed, 18 Mar 1998 13:35:27 +0100 (MET) From: MOLNAR Laszlo To: djgpp-workers AT delorie DOT com Subject: Re: libc replacement (memcmp) Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, Mar 17, 1998 at 12:53:21PM +0000, Burton Radons wrote: > memcmp used to compare using char-by-char, so I replaced it with > int-by-int -- quick optimizations, but it hadn't been done in three > years, so... bcmp follows this message. [...] Be careful with these kind of optimalizations! This version can produce SIGSEGV in some special cases where memcmp works. Here is how: assume that one of the pointers (say p1) looks like this: (p1 & 0xfff) = 0xffd. And assume that the address (p1+3) is not valid (this address is in the next page, which is not valid). If you try to call your version with memcmp (p1,p2,5) it will give you a SIGSEGV. However the original memcmp() can work depending on your data. So the two versions are not equivalent. bye, Laszlo