| 70 | } |
| 71 | |
| 72 | void free(void *ptr) |
| 73 | { |
| 74 | if (ptr == NULL) |
| 75 | return; |
| 76 | |
| 77 | if (ptr < (void *)&_heap || ptr >= free_mem_end_ptr) { |
| 78 | printk(BIOS_WARNING, "Pointer passed to %s is not " |
| 79 | "pointing to the heap\n", __func__); |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Rewind the heap pointer to the end of heap |
| 85 | * before the last successful malloc(). |
| 86 | */ |
| 87 | if (ptr == free_last_alloc_ptr) { |
| 88 | free_mem_ptr = free_last_alloc_ptr; |
| 89 | free_last_alloc_ptr = NULL; |
| 90 | } |
| 91 | } |