Lines Matching refs:alloc
28 * \param alloc pointer to the allocator state struct
33 bool msix_allocator_init(struct msix_allocator *alloc, size_t n)
35 alloc->count = n;
36 alloc->state = calloc((n + MSIX_ALLOCATOR_BITS -1 ) / MSIX_ALLOCATOR_BITS,
38 return (alloc->state != NULL);
45 * \param alloc the allocator to destroy
47 void msix_allocator_destory(struct msix_allocator *alloc)
49 if (alloc->state) {
50 free(alloc->state);
52 alloc->state = NULL;
53 alloc->count = 0;
59 * \param alloc pointer to the allocator state struct
64 bool msix_allocator_new(struct msix_allocator *alloc, size_t *ret_id)
66 size_t chunks = (alloc->count + MSIX_ALLOCATOR_BITS - 1) / MSIX_ALLOCATOR_BITS;
69 if (alloc->state[i] != 0xFF) {
73 if (!(j < alloc->count)) {
77 if (!(alloc->state[i] & (0x1 << idx))) {
78 alloc->state[i] |= (0x1 << idx);
93 * \param alloc pointer to the allocator state struct
98 bool msix_allocator_free(struct msix_allocator *alloc, size_t id)
102 if (id >= alloc->count) {
108 result = alloc->state[chunk] & (0x1 << shift);
109 alloc->state[chunk] &= ~(0x1 << shift);