=================================================================== RCS file: /home/cvs/OpenXM/src/ox_ntl/oxstack.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- OpenXM/src/ox_ntl/oxstack.c 2003/11/08 12:34:01 1.1 +++ OpenXM/src/ox_ntl/oxstack.c 2008/09/19 10:55:40 1.2 @@ -1,4 +1,4 @@ -/* $OpenXM$ */ +/* $OpenXM: OpenXM/src/ox_ntl/oxstack.c,v 1.1 2003/11/08 12:34:01 iwane Exp $ */ #include #include @@ -19,7 +19,7 @@ /* cmo stack */ static int G_ox_stack_size = 0; static int G_ox_stack_pointer = 0; -static cmo **G_ox_stack = NULL; +static oxstack_node **G_ox_stack = NULL; /*===========================================================================* @@ -51,7 +51,7 @@ oxstack_init_stack(void) G_ox_stack_pointer = 0; G_ox_stack_size = OXSERV_INIT_STACK_SIZE; - G_ox_stack = (cmo **)malloc(G_ox_stack_size * sizeof(cmo *)); + G_ox_stack = (oxstack_node **)malloc(G_ox_stack_size * sizeof(oxstack_node *)); if (G_ox_stack == NULL) { DPRINTF(("server: %d: %s\n", errno, strerror(errno))); return (OXSERV_FAILURE); @@ -69,13 +69,13 @@ int oxstack_extend_stack(void) { int size2 = G_ox_stack_size + OXSERV_EXT_STACK_SIZE; - cmo **stack2 = (cmo **)malloc(size2 * sizeof(cmo *)); + oxstack_node **stack2 = (oxstack_node **)malloc(size2 * sizeof(oxstack_node *)); if (stack2 == NULL) { DPRINTF(("server: %d: %s\n", errno, strerror(errno))); return (OXSERV_FAILURE); } - memcpy(stack2, G_ox_stack, G_ox_stack_size * sizeof(cmo *)); + memcpy(stack2, G_ox_stack, G_ox_stack_size * sizeof(oxstack_node *)); free(G_ox_stack); G_ox_stack = stack2; @@ -91,7 +91,7 @@ oxstack_extend_stack(void) * RETURN : if success return OXSERV_SUCCESS, else OXSERV_FAILURE. *****************************************************************************/ int -oxstack_push(cmo *m) +oxstack_push(oxstack_node *m) { int ret; @@ -107,6 +107,13 @@ oxstack_push(cmo *m) return (OXSERV_SUCCESS); } +int +oxstack_push_cmo(cmo *c) +{ + return (oxstack_push(oxstack_node_init(c))); +} + + /***************************************************************************** * remove thd CMO at the top of this stack and * returns that cmo as the value of this function. @@ -114,10 +121,10 @@ oxstack_push(cmo *m) * PARAM : NONE * RETURN : CMO at the top of the stack. *****************************************************************************/ -cmo * +oxstack_node * oxstack_pop(void) { - cmo *c; + oxstack_node *c; if (G_ox_stack_pointer > 0) { G_ox_stack_pointer--; c = G_ox_stack[G_ox_stack_pointer]; @@ -133,7 +140,7 @@ oxstack_pop(void) * PARAM : i : position in the stack. * RETURN: thd cmo at the specified position in the stack. *****************************************************************************/ -cmo * +oxstack_node * oxstack_get(int i) { if (i < G_ox_stack_pointer && i >= 0) { @@ -148,7 +155,7 @@ oxstack_get(int i) * PARAM : NONE * RETURN: the cmo at the top of the stack. *****************************************************************************/ -cmo * +oxstack_node * oxstack_peek(void) { return (oxstack_get(G_ox_stack_pointer - 1)); @@ -168,5 +175,23 @@ oxstack_dest(void) free(G_ox_stack); } + +/***************************************************************************** + * destroy + * + * PARAM : NONE + * RETURN: NONE + *****************************************************************************/ +oxstack_node * +oxstack_node_init(cmo *c) +{ + oxstack_node *p; + + p = malloc(sizeof(oxstack_node)); + memset(p, 0, sizeof(*p)); + + p->c = c; + return (p); +}