Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: memcopy, memmove Implementation

Reply
Thread Tools

Re: memcopy, memmove Implementation

 
 
Trewth Seeker
Guest
Posts: n/a
 
      07-14-2003
Richard Heathfield <> wrote in message news:<>...
> Steve Zimmerman wrote:
>
> > Kevin Easton wrote:
> >
> >> In comp.lang.c CBFalconer <> wrote:
> >>
> >>>Jonathan Leffler wrote:
> >>>
> >>>>CBFalconer wrote:
> >>>>
> >>>>>Kevin Easton wrote:
> >>>>>
> >>>>>>CBFalconer <> wrote:
> >>>>>>
> >>>>>>>I consider the const in the header to be a mistake. From N869:
> >>>>>>>
> >>>>>>>7.21.2.2 The memmove function
> >>>>>>>
> >>>>>>>Synopsis
> >>>>>>>
> >>>>>>>[#1]
> >>>>>>> #include <string.h>
> >>>>>>> void *memmove(void *s1, const void *s2, size_t n);

> >
> >
> > I believe that the const in the prototype refers to the void
> > pointer, not the value of s2.

>
> I believe that you believe that.
>
>
> > In other words, the pointer will
> > not be altered from type "pointer to void";

>
> Of course it won't. The const doesn't make any difference to the consistency
> of the type.
>
>
> > the value of s2 itself
> > may indeed be altered: not a mistake, my friend.

>
> To what would you alter s2? You can't do pointer arithmetic with it, so all
> you could do is point it to some other object altogether, in which case it
> isn't much use as a parameter any more.
>
> const void *s2 means that s2 points to an unknown object whose value must
> not be changed through this pointer.


It's useful to note that const is, by ancient unfortunate convention,
misplaced. Consider that const void *s2 is equivalent to
void const *s2, and that C declarations should be read backwards,
so this says that s2 is a pointer to a const void.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Memmove v/s Linked list Implementation getsanjay.sharma@gmail.com C Programming 15 02-01-2007 12:31 PM
memcpy verses memmove rinku24@yahoo.com C++ 2 02-14-2005 02:48 AM
Re: memcopy, memmove Implementation Micah Cowan C Programming 0 06-26-2003 02:52 AM
Re: memcopy, memmove Implementation Dan Pop C Programming 1 06-24-2003 01:42 PM
Re: memcopy, memmove Implementation Dan Pop C Programming 0 06-24-2003 12:17 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57