httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: cvs commit: apache-2.0/src/lib/apr/lib apr_hash.c
Date Tue, 11 Jul 2000 21:38:12 GMT
Greg Stein wrote:
> 
> On Mon, Jul 10, 2000 at 09:57:38AM +0100, Ben Laurie wrote:
> > gstein@locus.apache.org wrote:
> > >   -=head1 void *ap_hash_get(ap_hash_t *ht, void *key, size_t klen)
> > >   +=head1 void *ap_hash_get(ap_hash_t *ht, const void *key, size_t klen)
> >
> > Surely ap_hash_get() should return a const void *???
> 
> Nah. You might store a modifiable buffer into the hash table:
> 
>   buf = ap_pcalloc(p, BUFSIZE);
>   ap_hash_set(ht, "hello", 0, buf);
>   ...
> 
>   buf = ap_hash_get(ht, "hello", 0);
>   sprintf(buf, "%d/%d", foo, bar);
> 
> The get() function treats it as "const", and we store into the internal
> tables that way. But we drop the const right as we return it, since the
> notion of "const" is really up to the person who shoved the value in there.

In which case you should be honest about that and not mark the value you
store as const.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

Coming to ApacheCon Europe 2000? http://apachecon.com/

Mime
View raw message