Moved the interpreter
[repair.git] / Repair / RepairInterpreter / stack.c
diff --git a/Repair/RepairInterpreter/stack.c b/Repair/RepairInterpreter/stack.c
new file mode 100755 (executable)
index 0000000..ceb840a
--- /dev/null
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "stack.h"
+//#include "dmalloc.h"
+
+void pushstack(struct StackElement **septr,void * obj) {
+  struct StackElement * nse=(struct StackElement *)malloc(sizeof(struct StackElement));
+  nse->contents=obj;
+  nse->next=*septr;
+  *septr=nse;
+}
+
+void * popstack(struct StackElement **septr) {
+  if(*septr==NULL) {
+    printf("Empty Stack\n");
+    return NULL;/* Empty stack */
+  }
+  {
+    void *obj=(*septr)->contents;
+    struct StackElement *ose=*septr;
+    (*septr)=ose->next;
+    free(ose);
+    return obj;
+  }
+}