aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp4bl0 <r _at_ uzy .dot. me>2012-05-13 13:55:23 (CEST)
committerp4bl0 <r _at_ uzy .dot. me>2012-05-13 13:55:23 (CEST)
commit65e94985f4ae28af9d2e8e46b2e645afbdb454b5 (patch)
treef8640517f17bc52eb6e639ef676b3a8264e76b81
parent2502b2ff157242a512e7287e74076f7fbc2d9348 (diff)
downloadelispon-65e94985f4ae28af9d2e8e46b2e645afbdb454b5.zip
elispon-65e94985f4ae28af9d2e8e46b2e645afbdb454b5.tar.gz
oops, missing src/vector.{c,h} files
-rw-r--r--src/vector.c54
-rw-r--r--src/vector.h16
2 files changed, 70 insertions, 0 deletions
diff --git a/src/vector.c b/src/vector.c
new file mode 100644
index 0000000..9022b48
--- /dev/null
+++ b/src/vector.c
@@ -0,0 +1,54 @@
+#include "utils.h"
+#include "expression.h"
+#include "vector.h"
+
+struct Vector {
+ int size;
+ Expression **fields;
+};
+
+Vector *
+Vector_new (int size)
+{
+ Vector *self = NULL;
+
+ alloc_one(self);
+
+ self->size = size;
+ alloc_(self->fields, size);
+
+ return self;
+}
+
+void
+Vector_delete (Vector *self)
+{
+ int i;
+
+ if (self == NULL) return;
+ for (i = 0; i < self->size; i++)
+ Expression_delete(self->fields[i]);
+ free_(self);
+}
+
+/* ----- */
+
+int
+Vector_size (Vector *self)
+{
+ return self->size;
+}
+
+/* ----- */
+
+void
+Vector_set (Vector *self, int i, Expression *expr)
+{
+ self->fields[i] = expr;
+}
+
+Expression *
+Vector_get (Vector *self, int i)
+{
+ return self->fields[i];
+}
diff --git a/src/vector.h b/src/vector.h
new file mode 100644
index 0000000..fb82210
--- /dev/null
+++ b/src/vector.h
@@ -0,0 +1,16 @@
+#ifndef VECTOR_H__
+#define VECTOR_H__
+
+#include "expression.h"
+
+typedef struct Vector Vector;
+
+Vector *Vector_new (int size);
+void Vector_delete (Vector *self);
+
+int Vector_size (Vector *self);
+
+void Vector_set (Vector *self, int i, Expression *expr);
+Expression *Vector_get (Vector *self, int i);
+
+#endif /* VECTOR_H__ */
Pablo Rauzy — generated by cgit