00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <string.h>
00023 #include <flgrCoreMalloc.h>
00024 #include <flgrCoreDispatch.h>
00025 #include "flgrDataToolsStack.h"
00026
00027
00036 void flgr_stack_init(FLGR_Stack *stack) {
00037 stack->top = NULL;
00038 stack->next = NULL;
00039 stack->previous = NULL;
00040 stack->label = NULL;
00041 stack->size = 0;
00042 }
00043
00044 int flgr_stack_push(FLGR_Stack *stack, int x, int y, int z) {
00045 FLGR_StackLink *tmp = flgr_malloc(sizeof(FLGR_Stack));
00046
00047 tmp->lower = stack->top;
00048 tmp->x = x;
00049 tmp->y = y;
00050 tmp->z = z;
00051
00052 stack->size++;
00053
00054 stack->top = tmp;
00055
00056 return stack->size;
00057 }
00058
00059 int flgr_stack_pop(FLGR_Stack *stack, int *x, int *y, int *z) {
00060 FLGR_StackLink *tmp = stack->top;
00061
00062 if(stack->size<=0) return 0;
00063
00064 stack->size--;
00065
00066 tmp = stack->top;
00067 stack->top = tmp->lower;
00068
00069 *x = tmp->x;
00070 *y = tmp->y;
00071 *z = tmp->z;
00072
00073 flgr_free(tmp);
00074
00075 return stack->size;
00076 }
00077
00078 FLGR_Stack* flgr_stack_get_next(FLGR_Stack *stack) {
00079 return stack->next;
00080 }
00081
00082 FLGR_Stack* flgr_stack_get_previous(FLGR_Stack *stack) {
00083 return stack->previous;
00084 }
00085
00086 int flgr_stack_get_size(FLGR_Stack *stack) {
00087 return stack->size;
00088 }
00089
00090 void flgr_stack_flush(FLGR_Stack *stack) {
00091 int x,y,z;
00092 int v = flgr_stack_get_size(stack);
00093
00094 while(v>0) {
00095 v = flgr_stack_pop(stack,&x,&y,&z);
00096 }
00097 }
00098
00099
00100