changeset 122:22990a9ff28c

Redid how the memStack destroy function works, to call it without a function to apply to removed elements, pass it NULL
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sat, 18 Jun 2011 20:54:59 -0400
parents 889c68a0036a
children 2a35ea7e123b
files include/memStack.h src/os/memStack.c src/os/scall.c
diffstat 3 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/include/memStack.h	Fri Jun 17 09:09:09 2011 -0400
+++ b/include/memStack.h	Sat Jun 18 20:54:59 2011 -0400
@@ -18,7 +18,6 @@
 ErrCode msPop(MemStack *stack, Pointer *value);
 ErrCode msPush(MemStack *stack, Pointer value);
 MemStack* msInit();
-void msDestroyFN(MemStack *stack, void (*fn)(void*));
-void msDestroy(MemStack *stack);
+void msDestroy(MemStack *stack, void (*fn)(void*));
 
 #endif
--- a/src/os/memStack.c	Fri Jun 17 09:09:09 2011 -0400
+++ b/src/os/memStack.c	Sat Jun 18 20:54:59 2011 -0400
@@ -39,17 +39,12 @@
 	return;
 }
 
-void msDestroyFN(MemStack *stack, void (*fn)(void*))
+void msDestroy(MemStack *stack, void (*fn)(void*))
 {
 	Pointer point;
 	while(stack->top) {
 		msPop(stack, &point);
-		fn(point);
+		if(fn) fn(point);
 	}
 	free(stack);
 }
-
-void msDestroy(MemStack *stack)
-{
-	msDestroyFN(stack, doNothing);
-}
--- a/src/os/scall.c	Fri Jun 17 09:09:09 2011 -0400
+++ b/src/os/scall.c	Sat Jun 18 20:54:59 2011 -0400
@@ -20,7 +20,7 @@
 	switch(callCode) {
 		case SVC_EXIT:
 			if(ms) {
-				msDestroyFN(ms, freeHeap); //dynamic memory was used, kill it
+				msDestroy(ms, freeHeap); //dynamic memory was used, kill it
 				ms = NULL;
 			}
 			setcontext(&shellPsw, shellRegisters);