Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 59108
b: refs/heads/master
c: 7aae6dd
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Greg Kroah-Hartman committed Jul 11, 2007
1 parent d15f285 commit 82e6e5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc0afa8388972a9ed7c2203cc46d8df1a4713f65
refs/heads/master: 7aae6dd80e265aa9402ed507caaff4a5dba55069
16 changes: 14 additions & 2 deletions trunk/lib/idr.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ static int sub_alloc(struct idr *idp, void *ptr, int *starting_id)
int n, m, sh;
struct idr_layer *p, *new;
struct idr_layer *pa[MAX_LEVEL];
int l, id;
int l, id, oid;
long bm;

id = *starting_id;
restart:
p = idp->top;
l = idp->layers;
pa[l--] = NULL;
Expand All @@ -117,12 +118,23 @@ static int sub_alloc(struct idr *idp, void *ptr, int *starting_id)
if (m == IDR_SIZE) {
/* no space available go back to previous layer. */
l++;
oid = id;
id = (id | ((1 << (IDR_BITS * l)) - 1)) + 1;

/* if already at the top layer, we need to grow */
if (!(p = pa[l])) {
*starting_id = id;
return -2;
}
continue;

/* If we need to go up one layer, continue the
* loop; otherwise, restart from the top.
*/
sh = IDR_BITS * (l + 1);
if (oid >> sh == id >> sh)
continue;
else
goto restart;
}
if (m != n) {
sh = IDR_BITS*l;
Expand Down

0 comments on commit 82e6e5b

Please sign in to comment.