Hi!

26-Июл-2004 08:55 [EMAIL PROTECTED] (Roberto Mariottini)
wrote to [EMAIL PROTECTED]:

>> BTW: do you have information about memcpy() problems in BC 3.1 ? Last
>> week I had a very hard to trace bug (in a TSR) that was solved replacing
>> it with memmove(). Andreas sayd that he had problems with it too.
RM> Are you sure the two buffers you are memcpy-ing don't overlap? The

     BTW, good question.

RM> memcpy function assumes the two buffers don't overlap (neither by 1 byte),

     To be precise, on some platforms, on some implementations some
overlapping types are acceptable. For example, if implementation copies from
start of source, then result of copying will be valid when source start
address will be further, than dest. But there are no guarantees, that all
implementations always copy from start, so, result of memcpy() for
overlapping buffers is "implementation defined" and not neccessarily
portable accross implementations.

RM> making this assumption makes it work faster, but it fails on
RM> overlapping buffers. The memmove function doesn't make this assumption,
RM> so it works for overlapping buffers, at price of a slight decrease in
RM> performance.

     :) (On x86) decrease is constant and small - if source address is less
than dst, just copy from end to start instead from start to end.

RM> So the "replacing memcpy with memmove" may be a feature, not a bug :-)




-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
_______________________________________________
Freedos-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to