/* First time an entry is used, its base and size are set. An entry can be freed and re-malloc'd but its base & size don't change. Should be smart enough for needs of bootwrapper.  */
static void* simple_malloc(unsigned long size)
/* First time an entry is used, its base and size are set. An entry can be freed and re-malloc'd but its base & size don't change. Should be smart enough for needs of bootwrapper.  */
static void* simple_malloc(unsigned long size)
{
	unsigned long i;
	struct alloc_info *p = alloc_tbl;
	if (size == 0)
		goto err_out;
	size = _ALIGN_UP(size, alloc_min);
	for (i=0; i<tbl_entries; i++, p++)
		if (!(p->flags & ENTRY_BEEN_USED)) {
			if (size <= space_left) {
				p->base = next_base;
				p->size = size;
				p->flags = ENTRY_BEEN_USED | ENTRY_IN_USE;
				next_base += size;
				space_left -= size;
				return (void *)p->base;
			}
			goto err_out;
		}
		else if (!(p->flags & ENTRY_IN_USE) && (size <= p->size)) {
			p->flags |= ENTRY_IN_USE;
			return (void *)p->base;
		}
err_out:
	return NULL;
}