added a few error checks to stack and queue, need to test

This commit is contained in:
herbglitch 2024-02-08 03:17:04 -07:00
parent 314f490bef
commit b4eaee5242
2 changed files with 19 additions and 4 deletions

View file

@ -32,10 +32,20 @@ void ARC_Queue_Destroy(ARC_Queue *queue){
}
void ARC_Queue_Push(ARC_Queue *queue, void *data){
//TODO: check if size exceeds uint32_t
if(queue->currentSize == ~(uint32_t)0){
arc_errno = ARC_ERRNO_OVERFLOW;
ARC_DEBUG_ERR("ARC_Queue_Push(queue) called, size of queue is maxed, cannot add another node");
return;
}
ARC_QueueNode *end = queue->node;
for(uint32_t i = 0; i < queue->currentSize; i++){
//TODO: check if end->next exists
if(end == NULL){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_ERR("ARC_Queue_Push(queue), when getting end node encountered a NULL node");
return;
}
end = end->next;
}
@ -53,7 +63,7 @@ void *ARC_Queue_Pop(ARC_Queue *queue){
arc_errno = ARC_ERRNO_DATA;
ARC_DEBUG_ERR("ARC_Queue_Pop(queue) called, but queue was not empty");
return NULL;
}
}
ARC_QueueNode *node = queue->node;
if(node == NULL){