This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "../../common/misc/misc_utils.h"
|
||||
#include <string.h>
|
||||
|
||||
void _queuePush(WpQueue *queue, void *item, u64 item_size) {
|
||||
void queuePush(WpQueue *queue, void *item, u64 item_size) {
|
||||
wpDebugAssert(queue != NULL, "`queue` should not be NULL");
|
||||
wpRuntimeAssert(item_size == wpArrayItemSize(queue->items), "Invalid type");
|
||||
|
||||
@@ -14,7 +14,7 @@ void _queuePush(WpQueue *queue, void *item, u64 item_size) {
|
||||
if (queue->count >= capacity) { return; }
|
||||
|
||||
u64 index = (queue->back)++;
|
||||
_arraySet(queue->items, index, item, item_size);
|
||||
arraySet(queue->items, index, item, item_size);
|
||||
++(queue->count);
|
||||
|
||||
if (queue->back >= capacity) {
|
||||
@@ -22,7 +22,7 @@ void _queuePush(WpQueue *queue, void *item, u64 item_size) {
|
||||
}
|
||||
}
|
||||
|
||||
WpQueue *_queuePushAlloc(const WpAllocator *allocator, WpQueue *queue, void *item, u64 item_size) {
|
||||
WpQueue *queuePushAlloc(const WpAllocator *allocator, WpQueue *queue, void *item, u64 item_size) {
|
||||
wpDebugAssert(allocator != NULL && queue != NULL && item != NULL,
|
||||
"`allocator`, `queue` and `item` should not be NULL");
|
||||
wpRuntimeAssert(item_size == wpArrayItemSize(queue->items), "Invalid type");
|
||||
@@ -35,7 +35,7 @@ WpQueue *_queuePushAlloc(const WpAllocator *allocator, WpQueue *queue, void *ite
|
||||
b8 queue_full = queue->count >= capacity;
|
||||
if (queue_full) {
|
||||
u64 new_capacity = wpMiscUtilsU64RoundUpPow2(capacity * 2);
|
||||
u64 array_size = _arrayCalcAllocSize(new_capacity, item_size);
|
||||
u64 array_size = arrayCalcAllocSize(new_capacity, item_size);
|
||||
u64 alloc_size = sizeof(WpQueue) + array_size;
|
||||
void *buffer = wpMemAllocatorAlloc(allocator, alloc_size);
|
||||
if (!buffer) {
|
||||
@@ -45,7 +45,7 @@ WpQueue *_queuePushAlloc(const WpAllocator *allocator, WpQueue *queue, void *ite
|
||||
memset((void *)buffer, 0, alloc_size);
|
||||
|
||||
output = (WpQueue *)buffer;
|
||||
output->items = _arrayFromPreallocatedBuffer((void *)(output + 1), array_size, WP_ARRAY_INIT_FILLED, item_size);
|
||||
output->items = arrayFromPreallocatedBuffer((void *)(output + 1), array_size, WP_ARRAY_INIT_FILLED, item_size);
|
||||
|
||||
// NOTE (Abdelrahman): When the queue is full, the front and back indices should
|
||||
// always be the same
|
||||
@@ -84,13 +84,13 @@ WpQueue *_queuePushAlloc(const WpAllocator *allocator, WpQueue *queue, void *ite
|
||||
output->count = queue->count;
|
||||
}
|
||||
|
||||
_queuePush(output, item, item_size);
|
||||
queuePush(output, item, item_size);
|
||||
|
||||
RETURN_QUEUE_PUSH_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
void *_queuePop(WpQueue *queue, u64 item_size) {
|
||||
void *queuePop(WpQueue *queue, u64 item_size) {
|
||||
wpDebugAssert(queue != NULL, "`queue` should not be NULL");
|
||||
wpRuntimeAssert(item_size == wpArrayItemSize(queue->items), "Invalid type");
|
||||
|
||||
@@ -104,5 +104,5 @@ void *_queuePop(WpQueue *queue, u64 item_size) {
|
||||
queue->front = 0;
|
||||
}
|
||||
|
||||
return _arrayGet(queue->items, index, item_size);
|
||||
return arrayGet(queue->items, index, item_size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user