apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neil Conway <neil.con...@gmail.com>
Subject Re: apr_hash_set allocation failure behavior
Date Wed, 17 Mar 2010 22:35:11 GMT
On Wed, Mar 17, 2010 at 3:18 PM, Ivan Novick <inovick@greenplum.com> wrote:
> When adding to a hash table using apr_hash_set ... If memory can not be
> allocated what is the expected behavior?
> I am seeing apr_hash_set calls expand_array.
> expand_array core dumps if memory can not be allocated.
> Is this expected?  Is there a way to get an error code for a failed insert
> to a table rather than a coredump?

Seems easy enough to just make expand_array() give up if alloc_array()
fails: the next call to apr_hash_set() will try to expand the array
again (if warranted). See attached patch.

Note that I'd be hesitant to use apr_hash for large tables, unless you
can accurately pre-size it: see
http://markmail.org/message/ljylkgde37xf3wdm and related threads (the
referenced patch ultimately had to be reverted, because it broke code
that accessed hash tables from a cleanup function in the same pool).


View raw message