summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>1999-07-31 18:44:53 +0000
committerSimon Tatham <anakin@pobox.com>1999-07-31 18:44:53 +0000
commit0d14833a9c76c51cc7417d8fd60bec9d92714b8e (patch)
treec0716d398e83bc746baad088d5dfc215d5fea483 /misc.c
parent4c8c2b256ed01563a98b4cd820dc8ffef30d7fc1 (diff)
downloadhalibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.zip
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.gz
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.bz2
halibut-0d14833a9c76c51cc7417d8fd60bec9d92714b8e.tar.xz
Further development work. Parser nearly finished
[originally from svn r187]
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/misc.c b/misc.c
new file mode 100644
index 0000000..ec38016
--- /dev/null
+++ b/misc.c
@@ -0,0 +1,42 @@
+/*
+ * misc.c: miscellaneous useful items
+ */
+
+#include "buttress.h"
+
+struct stackTag {
+ void **data;
+ int sp;
+ int size;
+};
+
+stack stk_new(void) {
+ stack s;
+
+ s = smalloc(sizeof(*s));
+ s->sp = 0;
+ s->size = 0;
+ s->data = NULL;
+
+ return s;
+}
+
+void stk_free(stack s) {
+ sfree(s->data);
+ sfree(s);
+}
+
+void stk_push(stack s, void *item) {
+ if (s->size <= s->sp) {
+ s->size = s->sp + 32;
+ s->data = srealloc(s->data, s->size * sizeof(*s->data));
+ }
+ s->data[s->sp++] = item;
+}
+
+void *stk_pop(stack s) {
+ if (s->sp > 0)
+ return s->data[--s->sp];
+ else
+ return NULL;
+}