proc/resource alloc: fix logic and off-by-1 error
@@ -121,7 +121,7 @@ resource_t *resource_alloc(process_t *process, unsigned int *id)
t.id = *id;
r = lib_treeof(resource_t, linkage, lib_rbFindEx(process->resources.root, &t.linkage, resource_gapcmp));
if (r != NULL) {
- if (!(r->id < *id && (r->rmaxgap > *id - r->id)) || !(r->id > *id && (r->lmaxgap > r->id - *id))) {
+ if (!(r->id < *id && (r->rmaxgap >= *id - r->id)) && !(r->id > *id && (r->lmaxgap >= r->id - *id))) {
if (r->lmaxgap > 0)
*id = r->id - 1;
else
