- Timestamp:
- 03/09/07 10:00:09 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/void_stack.c
r81 r89 105 105 106 106 107 unsigned short void_stack_size( void_stack* stack)107 unsigned short void_stack_size(const void_stack* stack) 108 108 { 109 109 return stack->top; 110 } 111 112 113 void* void_stack_pop(void_stack* stack) 114 { 115 void* ret_val = NULL; 116 117 if(stack->top > 0) 118 { 119 ret_val = stack->elements[--(stack->top)]; 120 stack->elements[stack->top] = NULL; 121 } 122 123 return ret_val; 110 124 } 111 125 … … 123 137 124 138 125 void* void_stack_pop(void_stack* stack)139 const void* void_stack_cur(const void_stack* stack) 126 140 { 127 141 void* ret_val = NULL; 128 142 129 143 if(stack->top > 0) 130 { 131 ret_val = stack->elements[--(stack->top)]; 132 stack->elements[stack->top] = NULL; 133 } 134 else 135 ret_val = NULL; 144 ret_val = stack->elements[stack->top-1]; 136 145 137 146 return ret_val; … … 139 148 140 149 141 const void* void_stack_cur(void_stack* stack) 142 { 143 void* ret_val = NULL; 144 145 if(stack->top > 0) 146 ret_val = stack->elements[stack->top-1]; 147 else 148 ret_val = NULL; 149 150 return ret_val; 151 } 152 153 154 void_stack_iterator* void_stack_iterator_new(void_stack* stack) 150 void_stack_iterator* void_stack_iterator_new(const void_stack* stack) 155 151 { 156 152 void_stack_iterator* ret_val = NULL; 157 153 158 ret_val = (void_stack_iterator*)malloc(sizeof(void_stack_iterator)); 159 if (ret_val != NULL) 154 if(stack != NULL) 160 155 { 161 ret_val->stack = stack; 162 ret_val->cur = 0; 156 ret_val = (void_stack_iterator*)malloc(sizeof(void_stack_iterator)); 157 if (ret_val != NULL) 158 { 159 ret_val->stack = stack; 160 ret_val->cur = 0; 161 } 163 162 } 164 163
Note: See TracChangeset
for help on using the changeset viewer.