72 while (count < source->free_end) count *= 2;
77 destination->
count = count;
85 for (i = 0; i < source->
free_end; i++)
98 for (i = 0; i < table->
free_end; i++)
123 i = __objectGetMinHandle(
object);
124 if (i < table->free_begin) i = table->
free_begin;
131 table->
handles[i] = __objectAddRef(
object);
136 if (i >= table->
count)
138 uint32_t count = 2 * table->
count;
139 while (count < i) count *= 2;
143 if (table->
count >= count)
return -1;
147 table->
count = count;
154 table->
handles[i] = __objectAddRef(
object);
170 struct object *old_object;
175 if (handle >= table->
count)
177 uint32_t count = 2 * table->
count;
178 while (count < handle) count *= 2;
184 table->
count = count;
190 old_object = table->
handles[handle];
191 table->
handles[handle] = __objectAddRef(
object);
201 if (old_object) __objectRelease(old_object);
215 if (handle >= table->
free_end)
return NULL;
231 if (handle >= table->
free_end)
return false;
232 if (!(
object = table->
handles[handle]))
return false;
236 if (handle < table->free_begin)
248 uint32_t count = table->
count / 4;
252 table->
count = count;
258 __objectRelease(
object);
270 uint32_t i, count = 0;
271 for (i = 0; i < table->
free_end; i++)
273 if (table->
handles[i]) count++;
void handleForkTable(struct handleTable *destination, struct handleTable *source)
Forks a handle table.
void * heapReAlloc(void *addr, uint32_t length)
Resizes a block of kernel memory.
void * heapAlloc(uint32_t length)
Allocates a block of kernel memory.
void handleTableFree(struct handleTable *table)
Releases the memory of the handle table and all associated objects.
void * memset(void *ptr, int value, size_t num)
Fills a memory region with some specific byte value.
void heapFree(void *addr)
Deallocates a block of kernel memory.
uint32_t handleAllocate(struct handleTable *table, struct object *object)
Allocates a handle (index) for a specific kernel object.
bool handleRelease(struct handleTable *table, uint32_t handle)
Releases the object associated with a handle.
uint32_t handleCount(struct handleTable *table)
Returns the number of handles in a handletable.
void handleTableInit(struct handleTable *table)
Initializes the handle table structure which is part of each process.
struct object * handleGet(struct handleTable *table, uint32_t handle)
Returns the kernel object associated to a handle.
bool handleSet(struct handleTable *table, uint32_t handle, struct object *object)
Associates a handle (index) with a kernel object.