[BACK]Return to oxstack.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_ntl

Diff for /OpenXM/src/ox_ntl/oxstack.c between version 1.1 and 1.2

version 1.1, 2003/11/08 12:34:01 version 1.2, 2008/09/19 10:55:40
Line 1 
Line 1 
 /* $OpenXM$ */  /* $OpenXM: OpenXM/src/ox_ntl/oxstack.c,v 1.1 2003/11/08 12:34:01 iwane Exp $ */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 19 
Line 19 
 /* cmo stack */  /* cmo stack */
 static int G_ox_stack_size = 0;  static int G_ox_stack_size = 0;
 static int G_ox_stack_pointer = 0;  static int G_ox_stack_pointer = 0;
 static cmo **G_ox_stack = NULL;  static oxstack_node **G_ox_stack = NULL;
   
   
 /*===========================================================================*  /*===========================================================================*
Line 51  oxstack_init_stack(void)
Line 51  oxstack_init_stack(void)
   
         G_ox_stack_pointer = 0;          G_ox_stack_pointer = 0;
         G_ox_stack_size = OXSERV_INIT_STACK_SIZE;          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) {          if (G_ox_stack == NULL) {
                 DPRINTF(("server: %d: %s\n", errno, strerror(errno)));                  DPRINTF(("server: %d: %s\n", errno, strerror(errno)));
                 return (OXSERV_FAILURE);                  return (OXSERV_FAILURE);
Line 69  int
Line 69  int
 oxstack_extend_stack(void)  oxstack_extend_stack(void)
 {  {
         int size2 = G_ox_stack_size + OXSERV_EXT_STACK_SIZE;          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) {          if (stack2 == NULL) {
                 DPRINTF(("server: %d: %s\n", errno, strerror(errno)));                  DPRINTF(("server: %d: %s\n", errno, strerror(errno)));
                 return (OXSERV_FAILURE);                  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);          free(G_ox_stack);
   
         G_ox_stack = stack2;          G_ox_stack = stack2;
Line 91  oxstack_extend_stack(void)
Line 91  oxstack_extend_stack(void)
  * RETURN  : if success return OXSERV_SUCCESS, else OXSERV_FAILURE.   * RETURN  : if success return OXSERV_SUCCESS, else OXSERV_FAILURE.
  *****************************************************************************/   *****************************************************************************/
 int  int
 oxstack_push(cmo *m)  oxstack_push(oxstack_node *m)
 {  {
         int ret;          int ret;
   
Line 107  oxstack_push(cmo *m)
Line 107  oxstack_push(cmo *m)
         return (OXSERV_SUCCESS);          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   * remove thd CMO at the top of this stack and
  * returns that cmo as the value of this function.   * returns that cmo as the value of this function.
Line 114  oxstack_push(cmo *m)
Line 121  oxstack_push(cmo *m)
  * PARAM   : NONE   * PARAM   : NONE
  * RETURN  : CMO at the top of the stack.   * RETURN  : CMO at the top of the stack.
  *****************************************************************************/   *****************************************************************************/
 cmo *  oxstack_node *
 oxstack_pop(void)  oxstack_pop(void)
 {  {
         cmo *c;          oxstack_node *c;
         if (G_ox_stack_pointer > 0) {          if (G_ox_stack_pointer > 0) {
                 G_ox_stack_pointer--;                  G_ox_stack_pointer--;
                 c = G_ox_stack[G_ox_stack_pointer];                  c = G_ox_stack[G_ox_stack_pointer];
Line 133  oxstack_pop(void)
Line 140  oxstack_pop(void)
  * PARAM : i : position in the stack.   * PARAM : i : position in the stack.
  * RETURN: thd cmo at the specified position in the stack.   * RETURN: thd cmo at the specified position in the stack.
  *****************************************************************************/   *****************************************************************************/
 cmo *  oxstack_node *
 oxstack_get(int i)  oxstack_get(int i)
 {  {
         if (i < G_ox_stack_pointer && i >= 0) {          if (i < G_ox_stack_pointer && i >= 0) {
Line 148  oxstack_get(int i)
Line 155  oxstack_get(int i)
  * PARAM : NONE   * PARAM : NONE
  * RETURN: the cmo at the top of the stack.   * RETURN: the cmo at the top of the stack.
  *****************************************************************************/   *****************************************************************************/
 cmo *  oxstack_node *
 oxstack_peek(void)  oxstack_peek(void)
 {  {
         return (oxstack_get(G_ox_stack_pointer - 1));          return (oxstack_get(G_ox_stack_pointer - 1));
Line 168  oxstack_dest(void)
Line 175  oxstack_dest(void)
         free(G_ox_stack);          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);
   }
   
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>