/* search empty pages which may contain given size  */
static struct snd_util_memblk* search_empty(struct snd_util_memhdr *hdr, int size)
/* search empty pages which may contain given size  */
static struct snd_util_memblk* search_empty(struct snd_util_memhdr *hdr, int size)
{
	struct snd_util_memblk *blk, *prev;
	int page, psize;
	struct list_head *p;
	psize = get_aligned_page(size + ALIGN_PAGE_SIZE -1);
	prev = NULL;
	page = 0;
	list_for_each(p, &hdr->block) {
		blk = list_entry(p, struct snd_util_memblk, list);
		if (page + psize <= firstpg(blk))
			goto __found_pages;
		page = lastpg(blk) + 1;
	}
	if (page + psize > MAX_ALIGN_PAGES)
		return NULL;
__found_pages:
	blk = __snd_util_memblk_new(hdr, psize * ALIGN_PAGE_SIZE, p->prev);
	if (blk == NULL)
		return NULL;
	blk->offset = aligned_page_offset(page);
	firstpg(blk) = page;
	lastpg(blk) = page + psize - 1;
	return blk;
}