ssize_t rbmp_allocate(struct rbmp * b) { ssize_t id; if (!b) return bad_id(b); id = (ssize_t) bitmap_find_next_zero_area(b->bitmap, BITS_IN_BITMAP, 0, 1, 0); if (id < 0) return bad_id(b); bitmap_set(b->bitmap, id, 1); return id + b->offset; }
void parse_usb_id(const char *id) { unsigned long tmp; char *end; tmp = strtoul(id, &end, 16); if (*end != ':') bad_id(id); if (tmp > 0xffff) bad_id(id); vendor = tmp; tmp = strtoul(end+1, &end, 16); if (*end) bad_id(id); if (tmp > 0xffff) bad_id(id); product = tmp; }