Re: memcopy, memmove Implementation

Discussion in 'C Programming' started by Trewth Seeker, Jul 14, 2003.

  1. 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.
    Trewth Seeker, Jul 14, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Pop

    Re: memcopy, memmove Implementation

    Dan Pop, Jun 24, 2003, in forum: C Programming
    Replies:
    0
    Views:
    1,232
    Dan Pop
    Jun 24, 2003
  2. Dan Pop

    Re: memcopy, memmove Implementation

    Dan Pop, Jun 24, 2003, in forum: C Programming
    Replies:
    1
    Views:
    2,513
  3. Micah Cowan

    Re: memcopy, memmove Implementation

    Micah Cowan, Jun 26, 2003, in forum: C Programming
    Replies:
    0
    Views:
    844
    Micah Cowan
    Jun 26, 2003
  4. Replies:
    15
    Views:
    648
    Jorgen Grahn
    Feb 1, 2007
  5. JeanDean
    Replies:
    2
    Views:
    332
    Grizlyk
    Feb 13, 2007
Loading...

Share This Page