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

[MiNT] _kmr_get()



Quick question to anyone who may know:

In the function _kmr_get() in kmemory.c, there's some code that
reads something like this:

begin:
    - get the next free memory region pointer
    - remove the memory region pointer from the free list
    - initialize the memory region pointer
    - IF there are no more free memory region pointers on this page
        THEN look for next free memory region pointer on other pages
        IF no free memory region pointers were found on other pages
            THEN allocate another page for memory region pointers
            IF a page could be allocated
                THEN GOTO begin
            ELSE
                Re-attach the free block
                return NULL
     - Return a pointer to the memory region

My questions:

1)  Why do we re-try once we allocate a new page?  Don't we already
    have a region pointer?  What happens to the detached region pointer?
2)  Why are we returning NULL even though a free region pointer exists?
3)  Wouldn't it be better to put the existence check at the beginning
    rather than the middle?

Sorry if these are obvious questions.  I'm attempting to map out in
my brain and on paper how the memory management works in MiNT.

Thanks.

Michael White (michael@fastlane.net)