Am Dienstag, den 15.07.2008, 15:55 -0700 schrieb Dan Hipschman:
if (n < 0) n = 0; size = 12 + min( 300, n * 5 );
- dst = res = funcs.get_temp_buffer( n * 5 + 7 );
- dst = res = funcs.get_temp_buffer( size );
This looks like fixing an under-allocation, not over-allocation. The patched code allocates at least 5 bytes more, and never less than 312.
Regards, Michael Karcher
Michael Karcher wrote:
Am Dienstag, den 15.07.2008, 15:55 -0700 schrieb Dan Hipschman:
if (n < 0) n = 0; size = 12 + min( 300, n * 5 );
- dst = res = funcs.get_temp_buffer( n * 5 + 7 );
- dst = res = funcs.get_temp_buffer( size );
This looks like fixing an under-allocation, not over-allocation. The patched code allocates at least 5 bytes more, and never less than 312.
Never _more_ than 312, because MIN(300, x) <= 300.
tom
Am Mittwoch, den 16.07.2008, 16:10 +0200 schrieb Tomas Carnecky:
This looks like fixing an under-allocation, not over-allocation. The patched code allocates at least 5 bytes more, and never less than 312.
Never _more_ than 312, because MIN(300, x) <= 300.
Oops, got me. I like to read: min(300,x) as "300 is the minimum", which is plain wrong in any programming language that has min. SmallerOf would be more expressive, but min is perfectly OK. Perhaps I learn it some day.
Regards, Michael Karcher