uintptr_t bfl_alloc(bfl_t bfl) { /* Find empty int */ int found = 0; int pos, i; for (i = bfl->curpos; i < bfl->len; i++) { if (bfl->bitarray[i] != 0) { found = 1; break; } } if (found == 0) { for (i = 0; i < bfl->curpos; i++) { if (bfl->bitarray[i] != 0) { found = 1; break; } } } if (found == 0) { return -1UL; } pos = find_first_set(bfl->bitarray[i]); /* Unset the bit */ bfl->bitarray[i] &= ~(1UL << pos); if (bfl->bitarray == 0) bfl->curpos = (bfl->curpos + 1) % bfl->len; return (i * BITS_PER_LONG) + pos; }
vms$pointer sys$bfl_alloc(bfl_t bfl) { unsigned int found; unsigned int i; unsigned int pos; found = 0; for(i = bfl->curpos; i < bfl->len; i++) { if (bfl->bitarray[i] != 0) { found = 1; break; } } if (found == 0) { for(i = 0; i < bfl->curpos; i++) { if (bfl->bitarray[i] != 0) { found = 1; break; } } } if (found == 0) { return(-1); } pos = find_first_set(bfl->bitarray[i]); bfl->bitarray[i] &= ~(((bfl_word) 1) << pos); if (bfl->bitarray == 0) { bfl->curpos = (bfl->curpos + 1) % bfl->len; } return((i * BITS_PER_BFL_WORD) + pos); }