Re: out-of-mem handler



Sebastian Wilhelmi <wilhelmi@ira.uka.de> writes:
> 
> Letting realloc be overloaded seems silly as you simply can't know
> how much of the old mem has to be copied over to the new position,
> because the old length is unknown. Using the new length might lead
> to a segmentation fault. And letting malloc be overloaded, but not

If you also overload malloc you can store the length somewhere (though
indeed that's expensive); or in the gnome-session case the overloaded
version is just calling realloc(), only the error handling changes.
  
> I would propose adding the _try variants and leave the matter alone.
> 

I still think you get added value with an error handler, and it is
only 4 lines of code (maybe 6 or 7 if you want to have an accessor
function to get/set the handler), and since you only check handler !=
NULL if malloc fails there is no efficiency penalty.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]