/** * Free a block of memory, determining its size automatically. * * \param h Heap from which the block was allocated. * \param mem Pointer to a block of memory previously allocated with * either heap_malloc() or heap_calloc(). * * \note If \a mem is a NULL pointer, no operation is performed. * * \note Freeing the same memory block twice has undefined behavior. * * \note This function works like the ANSI C free(). */ void heap_free(struct Heap *h, void *mem) { size_t *_mem = (size_t *)mem; if (_mem) { --_mem; heap_freemem(h, _mem, *_mem); } }
/** * Free all the resources of all zombie processes previously added to the zombie * list. */ static void proc_freeZombies(void) { Process *proc; while (1) { PROC_ATOMIC(proc = (Process *)list_remHead(&zombie_list)); if (proc == NULL) return; if (proc->flags & PF_FREESTACK) { PROC_ATOMIC(heap_freemem(&proc_heap, proc->stack_base, proc->stack_size + PROC_SIZE_WORDS * sizeof(cpu_stack_t))); } } }