Strange prototype for memset

N

Noob

Hello,

My documentation for memset states

void *memset(const void *DST, int C, size_t LENGTH);

Strange prototype. That would make memset somewhat not very useful, it seems.
 
C

Chris M. Thomasson

Noob said:
Hello,

My documentation for memset states

void *memset(const void *DST, int C, size_t LENGTH);

Strange prototype. That would make memset somewhat not very useful, it
seems.

Must be a typo.
 
K

Keith Thompson

Noob said:
My documentation for memset states

void *memset(const void *DST, int C, size_t LENGTH);

Strange prototype. That would make memset somewhat not very useful,
it seems.

Where did you see that?

The correct prototype is

void *memset(void *s, int c, size_t n);
 
B

bartc

Noob said:
Hello,

My documentation for memset states

void *memset(const void *DST, int C, size_t LENGTH);

Strange prototype. That would make memset somewhat not very useful,
it seems.

Why not?
 
B

bartc

Kenneth Brody said:
Doesn't "const void *DST" mean that the function won't change what's
pointed to by DST?
Sounds like a typo in his documentation. What does the actual header file
say?

Maybe the author understood 'const' as well as I do. I would have guessed it
meant the pointer itself (inside memset()) couldn't be assigned to.
 
A

Alexander Bartolich

bartc said:
Kenneth Brody said:
[...]
Doesn't "const void *DST" mean that the function won't change what's
pointed to by DST?
Sounds like a typo in his documentation. What does the actual header file
say?

Maybe the author understood 'const' as well as I do. I would have guessed it
meant the pointer itself (inside memset()) couldn't be assigned to.

Keyword »const« applies to the thing at its left, unless there is nothing
at its left. So »const void *DST« is equivalent to »void const *DST« and
specifies that the »void« at its left is write-protected.

To write-protect the pointer itself you should specify »void *const DST«.
And of course you can combine the two things: »void const *const DST«.
 
R

Richard Bos

Noob said:
My documentation for memset states

void *memset(const void *DST, int C, size_t LENGTH);

Strange prototype. That would make memset somewhat not very useful, it seems.

Strange, indeed. Documentation from which source?

Richard
 
K

Keith Thompson

Keith Thompson said:
This is a bug in Cygwin and/or newlib. I've just posted a report on
the Cygwin mailing list:

<http://cygwin.com/ml/cygwin/2009-08/msg00748.html>

Note that the error is only in the man page; the actual declaration of
memset doesn't have the "const".

Response from Eric Blake at
<http://cygwin.com/ml/cygwin/2009-08/msg00754.html>:

| Indeed. However, this was already fixed in newlib on 2008-05-27, so it
| will be corrected the next time someone rebuilds the man pages.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top