Are zero size segment allowed?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Are zero size segment allowed?

kraftwerk1611
Hi,

If function alloc() is looking for available memory segment of length (size+2)=7 and it finds a memory block that has size=9 in its segment header, what should it do?

Taking out length 7 memory segment from this segment[size=9] will take all available available data part leaving only 2 segment header elements with zero data element.

Is this ok?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Are zero size segment allowed?

cadet1620
Administrator
kraftwerk1611 wrote
Taking out length 7 memory segment from this segment[size=9] will take all available available data part leaving only 2 segment header elements with zero data element.
This should be OK if it doesn't cause problems with your free list searching.  Requests for zero-length heap are rare—they only happen when a Jack object with no data members is constructed.

In might be better to treat this the same as finding a size=8 block; just return the entire block.

--Mark