Dynamic Storage Allocator Pros and Cons

Niels J|rgen Kruse njk at diku.dk
Thu Nov 22 08:21:47 AEST 1990


rh at smds.UUCP (Richard Harter) writes:

>Security and Error Checking:
>This is the reason for using G/R, if it matters to you.  Specifically
>the features are:
>(A)    All invalid size requests (zero, negative, too large) are trapped.
---------------------------------------------------^^^^^^^^^
Try ``getsp (2147483646,0)''.   ;-)

Another bug: The return value of malloc in GETNODES is never
checked, so if malloc returns NULL, getsp dump core quite
ungracefully.

BTW, Thanks for posting your Storage allocation package, it
makes what you have previously told about it a lot clearer.

PS: You call it a Best Fit allocator.  This is only true for
sizes smaller than 1Kb, for larger blocks the selection
strategy is LIFO.  This means that the memory utilization
achieved is quite a lot lower than that of a true Best Fit
storage allocator.

PPS: If you change the #define for BKSZ to
``( 65472 & (unsigned)-1/2 )'', the code will also work on a
Xenix286 system in large memory model.
-- 
Niels J|rgen Kruse 	DIKU Graduate 	njk at diku.dk



More information about the Comp.lang.c mailing list