Optimizing of explicit temporary storage

Giovanni Bajo giovannibajo@libero.it
Wed Oct 13 13:02:00 GMT 2004


Nick Ing-Simmons wrote:

>> it would be surprising to most programmers to optimize away the call
>> because malloc *does* have side-effects on real systems.  For
>> example, on UNIX, it is likely to call sbrk, which result in
>> observable changes in the process state.
> 
> Indeed! - I have actually written
> 
> free(malloc(estimated_total_need));
> 
> To get expensive sbrk() call out of the way with one big one
> rather than many smaller ones.

So why not calling sbrk() directly?

Giovanni Bajo




More information about the Gcc mailing list