diff options
author | Galin Simeonov <gts@volconst.com> | 2021-05-31 22:02:10 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:00:15 +0300 |
commit | 255a49ba5a41b3854dbdfebdec75fb6229450507 (patch) | |
tree | 616ea5786cb91d03ef609d32b402941dc30e926b /queue.c | |
parent | f768d9bdb84e846d89aac66a4f3433a44241c298 (diff) | |
download | MEGATRON-255a49ba5a41b3854dbdfebdec75fb6229450507.tar.gz |
added cmake file
Diffstat (limited to 'queue.c')
-rw-r--r-- | queue.c | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/queue.c b/queue.c deleted file mode 100644 index b395acf..0000000 --- a/queue.c +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef GQUEUE_C -#define GQUEUE_C GQUEUE_C -#include<queue.h> - - -void Queue_Init(struct Queue *q) -{ - q->first=q->last=NULL; - q->size=0; -} -void Queue_Push(struct Queue *q,void *data) -{ - if(q==NULL)return; - if(q->first==NULL) - { - q->first=q->last=malloc(sizeof(struct Queue_Node)); - - q->first->data=data; - q->first->prev=NULL; - - ++q->size; - }else - { - struct Queue_Node *temp=malloc(sizeof(struct Queue_Node)); - q->last->prev=temp; - temp->data=data; - temp->prev=NULL; - q->last=temp; - ++q->size; - } - -} -void* Queue_Pop(struct Queue *q) -{ - if(q==NULL)return NULL; - if(q->size==0)return NULL; - - void *return_value=q->first->data; - - if(q->size==1) - { - free(q->last); - q->first=q->last=NULL; - q->size=0; - }else - { - struct Queue_Node *temp_first=q->first; - q->first=q->first->prev; - free(temp_first); - --q->size; - } - return return_value; -} -void Queue_Destroy(struct Queue *q) -{ - - struct Queue_Node *temp_first; - while(q->first!=NULL) - { - temp_first=q->first; - q->first=q->first->prev; - free(temp_first->data); - free(temp_first); - } - -} -#endif |