aboutsummaryrefslogtreecommitdiff
path: root/vector.inc.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-18 22:39:56 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-18 22:39:56 +0100
commit33fa5b5d0c512c72c1d50b9420a36431cd10eb5d (patch)
tree6642ec876ecd15ce62f83075d7f9d261050fe3a6 /vector.inc.h
parentStart rework of guile interface. (diff)
downloadcalp-33fa5b5d0c512c72c1d50b9420a36431cd10eb5d.tar.gz
calp-33fa5b5d0c512c72c1d50b9420a36431cd10eb5d.tar.xz
Made to compile as C++.
Diffstat (limited to 'vector.inc.h')
-rw-r--r--vector.inc.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/vector.inc.h b/vector.inc.h
index f6d1c796..2b23eadc 100644
--- a/vector.inc.h
+++ b/vector.inc.h
@@ -1,51 +1,51 @@
#ifndef TYPE
-#error "Set TYPE before including this file"
+#error "Set TYPE before including self file"
#else
#include "macro.h"
#include "err.h"
INIT_F(VECT(TYPE)) {
- this->length = 0;
- this->alloc = 1;
- this->items = calloc(sizeof(*this->items), this->alloc);
+ self->length = 0;
+ self->alloc = 1;
+ self->items = (TYPE**) calloc(sizeof(*self->items), self->alloc);
return 0;
}
FREE_F(VECT(TYPE)) {
- for (unsigned int i = 0; i < this->length; i++) {
- FFREE(TYPE, this->items[i]);
+ for (unsigned int i = 0; i < self->length; i++) {
+ FFREE(TYPE, self->items[i]);
}
- free(this->items);
+ free(self->items);
return 0;
}
-int PUSH(VECT(TYPE))(VECT(TYPE)* this, TYPE* t) {
- if (this->length + 1 > this->alloc) {
- this->alloc <<= 1;
- this->items = realloc(this->items, sizeof(*this->items) * this->alloc);
+int PUSH(VECT(TYPE))(VECT(TYPE)* self, TYPE* t) {
+ if (self->length + 1 > self->alloc) {
+ self->alloc <<= 1;
+ self->items = (TYPE**) realloc(self->items, sizeof(*self->items) * self->alloc);
}
- this->items[this->length] = t;
- ++this->length;
+ self->items[self->length] = t;
+ ++self->length;
return 0;
}
-TYPE* GET(VECT(TYPE))(VECT(TYPE)* this, unsigned int idx) {
- if (idx >= this->length) {
+TYPE* GET(VECT(TYPE))(VECT(TYPE)* self, unsigned int idx) {
+ if (idx >= self->length) {
ERR("Index out of range");
return NULL;
}
- return this->items[idx];
+ return self->items[idx];
}
-int EMPTY(VECT(TYPE))(VECT(TYPE)* this) {
- return this->length == 0;
+int EMPTY(VECT(TYPE))(VECT(TYPE)* self) {
+ return self->length == 0;
}
-unsigned int SIZE(VECT(TYPE))(VECT(TYPE)* this) {
- return this->length;
+unsigned int SIZE(VECT(TYPE))(VECT(TYPE)* self) {
+ return self->length;
}
#endif /* TYPE */