Changeset 38 for trunk/lib


Ignore:
Timestamp:
07/31/05 11:00:59 (19 years ago)
Author:
tim
Message:

Cleaned up path2Stack. Added several supporting functions in void_stack code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/void_stack.c

    r33 r38  
    5050
    5151
     52void_stack* void_stack_copy(const void_stack* v)
     53{
     54  unsigned int i;
     55  void_stack* ret_val;
     56  if(v == NULL)
     57    return NULL;
     58
     59  ret_val = void_stack_new(v->max_size);
     60  if(ret_val == NULL)
     61    return NULL;
     62
     63  for(i = 0; i < v->top; i++)
     64    ret_val->elements[i] = v->elements[i];
     65  ret_val->top = v->top;
     66
     67  return ret_val;
     68}
     69
     70
     71void_stack* void_stack_copy_reverse(const void_stack* v)
     72{
     73  unsigned int i;
     74  void_stack* ret_val;
     75  if(v == NULL)
     76    return NULL;
     77
     78  ret_val = void_stack_new(v->max_size);
     79  if(ret_val == NULL)
     80    return NULL;
     81
     82  for(i = 0; i < v->top; i++)
     83    ret_val->elements[i] = v->elements[v->top-i-1];
     84  ret_val->top = v->top;
     85
     86  return ret_val;
     87}
     88
     89
    5290void void_stack_destroy(void_stack* stack)
     91{
     92  free(stack);
     93}
     94
     95
     96void void_stack_destroy_deep(void_stack* stack)
    5397{
    5498  unsigned short i;
Note: See TracChangeset for help on using the changeset viewer.