Liste des Groupes | Revenir à c arch |
On Thu, 5 Sep 2024 13:48:37 +0000, David Brown wrote:They can do that if they want - memcpy can be implemented using memmove, but not vice versa.
On 04/09/2024 20:13, MitchAlsup1 wrote:There are compilers that:: s/memcpy/memmove/gOn Wed, 4 Sep 2024 17:53:13 +0000, David Brown wrote:>
>On 04/09/2024 18:07, Tim Rentsch wrote:>>If all the records are in one large array, there is a simple>
test to see if memcpy() must work or whether some alternative
should be used instead.
Such tests are usually built into implementations of memmove(), which
will chose to run forwards or backwards as needed. So you might as well
just call memmove() any time you are not sure memcpy() is safe and
appropriate.
Memmove() is always appropriate unless you are doing something
nefarious.
So:
# define memcpy memomve
and move forward with life--for the 2 extra cycles memmove costs it
saves everyone long term grief.
>
Or just use memmove, and not memcpy, whenever you are moving stuff
around in the same buffer.
>When you need the nefarious activities of memcpy write it as a>
for loop by yourself and comment the nafariousness of the use.
memcpy is not nefarious. It's quite simple, and does what it says on
the tin. Use it when you want to copy non-overlapping memory areas.
Don't use it if you want to do something other than that. I have never
understood why anyone would find this difficult.
Les messages affichés proviennent d'usenet.