Comment 1 for bug 447237

Revision history for this message
Monty Taylor (mordred) wrote : Re: [Bug 447237] [NEW] const-correctness in interface

I'm all for any const correctness fixes.

Fred Richards wrote:
> Public bug reported:
>
> All the function declarations that contain this:
>
> (... const char **keys, size_t *key_length, ...)
>
> should be:
>
> (... const char * const *keys, const size_t *key_length, ...)
>
> (and the man pages fixed). The way the interfaces are declared in 0.33,
> this, e.g:
>
> char **keys /* to be alloc'd and filled in */;
> size_t *len /* same */;
>
> rc = memcached_mget(stptr, keys, len, count);
>
> results in the following error from GCC 4.x: "invalid conversion from
> 'char**' to 'const char**'". Legacy code that was written to the API
> prior to the introduction of the const qualifiers (< 0.21?) therefore
> does not build with the newer API (and newer GCC). An explicit (const
> char **) cast of the keys argument is required, as is done throughout
> the libmemcached code with calls to memcached_key_test().
>
> You can grep for 'const char \*\*' to find all the places that need the
> added const qualifiers. WIth the correct const qualifiers the explicit
> casts on the memcached_key_test() argument that will no longer be
> necessary.
>
> The changes do not alter the regression test results.
>
> ** Affects: libmemcached
> Importance: Undecided
> Status: New
>