basic queue written, still need to test

This commit is contained in:
herbglitch 2024-02-08 03:12:37 -07:00
parent c3b4a4e209
commit 314f490bef
4 changed files with 140 additions and 6 deletions

View file

@ -24,7 +24,7 @@ void ARC_Stack_Create(ARC_Stack **stack){
void ARC_Stack_Destroy(ARC_Stack *stack){
if(stack->currentSize != 0 || stack->node != NULL){
arc_errno = ARC_ERRNO_DATA;
ARC_DEBUG_ERR("ARC_Stack_Destroy called, but stack was not empty");
ARC_DEBUG_ERR("ARC_Stack_Destroy(stack) called, but stack was not empty");
return;
}
@ -32,6 +32,7 @@ void ARC_Stack_Destroy(ARC_Stack *stack){
}
void ARC_Stack_Push(ARC_Stack *stack, void *data){
//TODO: check if size exceeds uint32_t
ARC_StackNode *node = (ARC_StackNode *)malloc(sizeof(ARC_StackNode));
node->data = data;
node->next = NULL;
@ -45,14 +46,14 @@ void ARC_Stack_Push(ARC_Stack *stack, void *data){
void *ARC_Stack_Pop(ARC_Stack *stack){
if(stack->currentSize == 0){
arc_errno = ARC_ERRNO_DATA;
ARC_DEBUG_ERR("ARC_Stack_Pop called, but stack was not empty");
ARC_DEBUG_ERR("ARC_Stack_Pop(stack) called, but stack was not empty");
return NULL;
}
ARC_StackNode *node = stack->node;
if(node == NULL){
arc_errno = ARC_ERRNO_NULL;
ARC_DEBUG_ERR("ARC_Stack_Pop called, but node was NULL");
ARC_DEBUG_ERR("ARC_Stack_Pop(stack) called, but node was NULL");
return NULL;
}