-
Notifications
You must be signed in to change notification settings - Fork 750
Description
From [email protected] on February 17, 2009 14:05:24
protobuf-c uses a flexible pluggable allocator scheme to permit clients of
the library to adapt it to any kind of memory allocator. There is also a
hook allowing the standard allocator's response to allocation failure to be
customized. Unfortunately, this flexibility is of limited use because the
uses of the allocator in the protobuf-c library don't check for allocation
failure, meaning that the default behavior of aborting when out of memory
is pretty much the only available option.
For my project I needed robustness against alloc failure, and aborting the
program is not acceptable. The attached patch tries to make it so that all
calls into the protobuf-c lib either complete all allocations successfully,
or unwind all partial allocations and return NULL. Please consider it for
inclusion in the standard protobuf-c distribution.
Two unit tests were added to test the new behavior, but they don't yet
cover all allocation code paths in library.
Attachment: protobuf-c-alloc-fail.patch
Original issue: http://code.google.com/p/protobuf-c/issues/detail?id=15