aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcathook <cat.hook31894@gmail.com>2013-12-17 00:17:12 +0800
committercathook <cat.hook31894@gmail.com>2013-12-17 00:17:12 +0800
commit92fc771515af38e384396692058fd147b79b2ba7 (patch)
treeb63411ea9d6bb4e60b9c6513c40fc23d3e1f5971
parentfeaff2b2082371099da269da1210bca6557004f8 (diff)
parent54d2304f9e8a2d027e1a6d278beecfafde3ad537 (diff)
downloadctl-92fc771515af38e384396692058fd147b79b2ba7.tar.gz
ctl-92fc771515af38e384396692058fd147b79b2ba7.tar.zst
ctl-92fc771515af38e384396692058fd147b79b2ba7.zip
Merge branch 'feature-queue' into develop
Conflicts: inc/stack.h src/stack.c
-rw-r--r--inc/queue.h6
-rw-r--r--src/queue.c10
2 files changed, 10 insertions, 6 deletions
diff --git a/inc/queue.h b/inc/queue.h
index 6799407..7bb317b 100644
--- a/inc/queue.h
+++ b/inc/queue.h
@@ -7,10 +7,10 @@ pvoid ctl_queue_initX(ppvoid q, uint size);
pvoid ctl_queue_freeX(ppvoid q);
uint ctl_queue_getEntrySizeX(ppcvoid q);
-pcvoid ctl_queue_getFrontX (ppcvoid q);
int ctl_queue_isEmptyX (ppcvoid q);
+pvoid ctl_queue_getX ( ppvoid q);
-pcvoid ctl_queue_addX(ppvoid q, pcvoid data);
+pvoid ctl_queue_addX(ppvoid q, pcvoid data);
int ctl_queue_delX(ppvoid q);
pvoid ctl_queue_copyX(ppcvoid q, ppvoid q2);
@@ -19,8 +19,8 @@ pvoid ctl_queue_copyX(ppcvoid q, ppvoid q2);
#define ctl_queue_free(X) ctl_queue_freeX(ppVoid(X))
#define ctl_queue_getEntrySize(X) ctl_queue_getEntrySizeX(ppcVoid(X))
-#define ctl_queue_getFront(X) ctl_queue_getFrontX (ppcVoid(X))
#define ctl_queue_isEmpty(X) ctl_queue_isEmptyX (ppcVoid(X))
+#define ctl_queue_get(X) ctl_queue_getX (ppcVoid(X))
#define ctl_queue_add(X,Y) ctl_queue_addX(ppVoid(X),pcVoid(Y))
#define ctl_queue_del(X) ctl_queue_delX(ppVoid(X))
diff --git a/src/queue.c b/src/queue.c
index 2ab9939..0ebfd49 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -25,6 +25,7 @@ typedef struct QueueHeadStruct QueueHead;
#define getHead(X) (((QueueNode*)(pChar(X)-offsetof(QueueNode, buf)))->head)
#define getSize(X) (sizeof(QueueNode) + (getHead(X)->size))
+/************ constructure / destructure ******************/
pvoid ctl_queue_initX(ppvoid q, uint size){
QueueHead* head = (QueueHead*)ctl_malloc(sizeof(QueueHead));
head->size = size;
@@ -50,18 +51,21 @@ pvoid ctl_queue_freeX(ppvoid q){
return NULL;
}
+/********************* get??? method **********************/
uint ctl_queue_getEntrySizeX(ppcvoid q){
return getHead(*q)->size;
}
-
-pcvoid ctl_queue_getX(ppcvoid q){
+
+pvoid ctl_queue_getX(ppvoid q){
return *q;
}
+
+/******************* queue's methods **********************/
int ctl_queue_isEmptyX(ppcvoid q){
return (getHead(*q)->first == NULL ? 1 : 0);
}
-pcvoid ctl_queue_addX(ppvoid q, pcvoid data){
+pvoid ctl_queue_addX(ppvoid q, pcvoid data){
QueueHead* head = getHead(*q);
if(head->first == NULL){
head->first = (QueueNode*)ctl_malloc(getSize(*q));