Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 8 May 2013 07:58:46 +0400
From: Solar Designer <>
Subject: Re: Constification and format interface clarification

On Wed, May 08, 2013 at 01:40:00AM +0200, magnum wrote:
> On 8 May, 2013, at 0:46 , Alexander Cherepanov <> wrote:
> > 1. Constification. IMHO it would be good to add a "const" qualifier to function parameters when they are pointers pointing to data which is not modified. It will guarantee that string literals are not modified, make the code more robust, perhaps permit more optimizations etc.

Thank you for locating this posting in the archive.

> I would be eager to do this if there was significant performance gains to win.

As the posting referenced above indicates, there's absolutely no
performance gain to expect from constifying the pointers.

There is potential performance gain from use of the restrict keyword,
but it may also make the code less robust (some of those uses of
restrict may be bugs, right away or at a later time).

> The "bug protection" alone might not be worth it.

I think the added clarity is worth it.  We could write a comment that
"this function does not alter the memory area referred to by its pointer
argument" or we could simply add const.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.