F
Flash Gordon
But why am I overlapping my data copies?
One reason was given just below this question. What is wrong with the
given reason?
Well, I see where you are coming from now, but I find it hard to
believe an index array can be very time consuming on modren computers.
Why would you want to write a for loop and use indexing when you can
make a single library call?
Anyway, if a simple for loop is the most efficient method then the
library is likely to use that method.
I suppose if you had thousands of pointers, but then you would want a
linked-list, wouldn't you? And by then, you'd want an ISAM structure
or something.
When doing a text editor will you have a linked list of characters so
you can insert and delete characters? I think not. You might have a
linked list of blocks of of text, but you will still have to insert in
to and delete from the middle of a block, and the simple way to do that
is with memmove.
My point was, if it's small and known, you might be better off using a
for loop or two memcopy's, and if it's big enough then a memmove() is
inappropriate because you should be using something better.
Why write a loop or do a malloc/memcpy/memcpy/free (you can't use a
static buffer if the amount of data is variable) when a single memmove
will do the job correctly?
Either way the programmer should control what happens. However, I have
been mistaken before.
When you call memmove you ARE in control. It is well defined what will
happen and you call it because that is the right thing to do.