malloc question

Denys Vlasenko vda.linux at googlemail.com
Thu Nov 6 15:17:02 UTC 2008


On Thu, Nov 6, 2008 at 11:57 AM, Will Wagner <will_wagner at carallon.com> wrote:
> I am looking for some help on an issue I am having with malloc and running out of memory.
>
> I would like to get some notification in our application if a memory allocation fails with
> ENO_MEM when using malloc. Most of our application is C++ and so uses new where we can
> call set_new_handler so that we get a callback when we run out of memory. However a number
> of libs use malloc so I would like to implement similar functionality.
>
> I have looked at the source code for standard malloc and it doesn't appear to be any
> support for this.
>
> Can anyone suggest a good way to address this issue?

A hook to call on malloc failure would be nice.
Too bad standards don't specify it, but maybe we can provide one
as an uclibc extension.

I would vote "yes" for such addition.
--
vda



More information about the uClibc mailing list