/* This function finds the next LEB that was allocated by the alloc_lpt_leb function starting from @lnum. If a LEB is found it is returned in @lnum and the function returns %0. Otherwise the function returns -ENOSPC. Note however, that LPT is designed never to run out of space.  */
static int realloc_lpt_leb(struct ubifs_info *c, int *lnum)
/* This function finds the next LEB that was allocated by the alloc_lpt_leb function starting from @lnum. If a LEB is found it is returned in @lnum and the function returns %0. Otherwise the function returns -ENOSPC. Note however, that LPT is designed never to run out of space.  */
static int realloc_lpt_leb(struct ubifs_info *c, int *lnum)
{
	int i, n;
	n = *lnum - c->lpt_first + 1;
	for (i = n; i < c->lpt_lebs; i++)
		if (c->ltab[i].cmt) {
			c->ltab[i].cmt = 0;
			*lnum = i + c->lpt_first;
			return 0;
		}
	for (i = 0; i < n; i++)
		if (c->ltab[i].cmt) {
			c->ltab[i].cmt = 0;
			*lnum = i + c->lpt_first;
			return 0;
		}
	return -ENOSPC;
}