switch to C
authorbdemsky <bdemsky@uci.edu>
Wed, 14 Jun 2017 23:51:13 +0000 (16:51 -0700)
committerbdemsky <bdemsky@uci.edu>
Wed, 14 Jun 2017 23:51:13 +0000 (16:51 -0700)
21 files changed:
src/Makefile
src/boolean.h
src/classlist.h
src/csolver.c
src/csolver.h
src/element.c
src/element.h
src/function.h
src/mutableset.c
src/mutableset.h
src/mymemory.h
src/order.c
src/order.h
src/predicate.h
src/set.c
src/set.h
src/stl-model.h [deleted file]
src/structs.c [new file with mode: 0644]
src/structs.h [new file with mode: 0644]
src/table.h
src/vector.h [new file with mode: 0644]

index 548189ef94762759b635481cfc31d02d5e8b8efc..dae27b77f1d0c7cb0255e3714c695eabf504af99 100644 (file)
@@ -4,7 +4,7 @@ PHONY += directories
 MKDIR_P = mkdir -p
 OBJ_DIR = bin
 
-CPP_SOURCES := constraint.cc inc_solver.cc set.cc mutableset.cc element.cc function.cc order.cc table.cc predicate.cc boolean.cc csolver.cc
+CPP_SOURCES := set.cc mutableset.cc element.cc function.cc order.cc table.cc predicate.cc boolean.cc csolver.cc structs.c
 
 OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
 
index 98e727e8416bab5d016343466debbbced2c85195..5e8c5a5e6f9a225af80543f9d1fc4b2f1411cd14 100644 (file)
@@ -3,9 +3,6 @@
 #include "classlist.h"
 #include "mymemory.h"
 
-class Boolean {
- public:
-       MEMALLOC;
- private:
+struct  Boolean {
 };
 #endif
index 53555ed87c88778bac05688a6cfb30fbfdce6c43..c6a7cb7f434902896e69c9f0cf20a4bf3687458e 100644 (file)
@@ -9,9 +9,15 @@
 
 #ifndef CLASSLIST_H
 #define CLASSLIST_H
-#include "hashset.h"
+//#include "hashset.h"
 #include "mymemory.h"
 #include <inttypes.h>
+#define bool int
+#define true 1
+#define false 0
+
+struct CSolver;
+typedef struct CSolver CSolver;
 
 struct Constraint;
 typedef struct Constraint Constraint;
@@ -20,7 +26,7 @@ struct Boolean;
 typedef struct Boolean Boolean;
 
 struct IncrementalSolver;
-typedef struct IncrementSolver IncrementalSolver;
+typedef struct IncrementalSolver IncrementalSolver;
 
 struct Set;
 typedef struct Set Set;
@@ -34,7 +40,7 @@ struct Function;
 typedef struct Function Function;
 
 struct Predicate;
-typedef struct Predicat Predicate;
+typedef struct Predicate Predicate;
 
 struct Table;
 typedef struct Table Table;
index 20e729a5ef391ee0c86b46703d204df64e98e523..a6dde8fe27489b4e775ba39ce441ceb0cc9d80ea 100644 (file)
@@ -2,64 +2,79 @@
 
 CSolver * allocCSolver() {
        CSolver * tmp=(CSolver *) ourmalloc(sizeof(CSolver));
-       tmp->constraint=allocVector();
+       tmp->constraint=allocDefVectorBoolean();
        return tmp;
 }
 
-Set * createSet(CSolver * solver, Type type, uint64_t ** elements) {
-       
+Set * createSet(CSolver * solver, VarType type, uint64_t ** elements) {
+       return NULL;
 }
 
-Set * createSet(CSolver * solver, Type type, uint64_t lowrange, uint64_t highrange) {
+Set * createRangeSet(CSolver * solver, VarType type, uint64_t lowrange, uint64_t highrange) {
+       return NULL;
 }
 
-MutableSet * createMutableSet(CSolver * solver, Type type) {
+MutableSet * createMutableSet(CSolver * solver, VarType type) {
+       return NULL;
 }
 
-void CSolver::addItem(MutableSet * set, uint64_t element) {
+void addItem(CSolver *solver, MutableSet * set, uint64_t element) {
 }
 
-int64_t CSolver::createUniqueItem(MutableSet * set) {
+int64_t createUniqueItem(CSolver *solver, MutableSet * set) {
+       return 0;
 }
 
-Element * CSolver::getElementVar(Set * set) {
+Element * getElementVar(CSolver *solver, Set * set) {
+       return NULL;
 }
 
-Boolean * CSolver::getBooleanVar() {
+Boolean * getBooleanVar(CSolver *solver) {
+       return NULL;
 }
 
-Function * CSolver::createFunctionOperator(enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus) {
+Function * createFunctionOperator(CSolver *solver, enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus) {
+       return NULL;
 }
 
-Function * CSolver::createFunctionOperator(enum ArithOp op) {
+Function * createFunctionOperatorPure(CSolver *solver, enum ArithOp op) {
+       return NULL;
 }
 
-Predicate * CSolver::createPredicateOperator(enum CompOp op, Set ** domain) {
+Predicate * createPredicateOperator(CSolver *solver, enum CompOp op, Set ** domain) {
+       return NULL;
 }
 
-Table * CSolver::createTable(Set **domains, Set * range) {
+Table * createTable(CSolver *solver, Set **domains, Set * range) {
+       return NULL;
 }
 
-void CSolver::addTableEntry(Element ** inputs, Element *result) {
+void addTableEntry(CSolver *solver, Element ** inputs, Element *result) {
 }
 
-Function * CSolver::completeTable(struct Table *) {
+Function * completeTable(CSolver *solver, Table * table) {
+       return NULL;
 }
 
-Element * CSolver::applyFunction(Function * function, Element ** array) {
+Element * applyFunction(CSolver *solver, Function * function, Element ** array) {
+       return NULL;
 }
 
-Boolean * CSolver::applyPredicate(Predicate * predicate, Element ** inputs) {
+Boolean * applyPredicate(CSolver *solver, Predicate * predicate, Element ** inputs) {
+       return NULL;
 }
 
-Boolean * CSolver::applyLogicalOperation(enum LogicOp op, Boolean ** array) {
+Boolean * applyLogicalOperation(CSolver *solver, enum LogicOp op, Boolean ** array) {
+       return NULL;
 }
 
-void CSolver::addBoolean(Boolean * constraint) {
+void addBoolean(CSolver *solver, Boolean * constraint) {
 }
 
-Order * CSolver::createOrder(enum OrderType type, Set * set) {
+Order * createOrder(CSolver *solver, enum OrderType type, Set * set) {
+       return NULL;
 }
 
-Boolean * CSolver::orderedConstraint(Order * order, uint64_t first, uint64_t second) {
+Boolean * orderConstraint(CSolver *solver, Order * order, uint64_t first, uint64_t second) {
+       return NULL;
 }
index b03adb713598e7a1f59a0c0f6e2cc1f4dfb0adc8..7b2d65924c917aff764afb476d5ca3c49799dd43 100644 (file)
@@ -2,38 +2,38 @@
 #define CSOLVER_H
 #include "classlist.h"
 #include "ops.h"
+#include "structs.h"
 
-class CSolver {
-public:
-       CSolver();
-       Set * createSet(Type type, uint64_t ** elements);
-       Set * createSet(Type type, uint64_t lowrange, uint64_t highrange);
-       MutableSet * createMutableSet(Type type);
+struct CSolver {
+       VectorBoolean * constraint;
+};
+       
+CSolver * allocCSolver();
+Set * createSet(CSolver *, VarType type, uint64_t ** elements);
+Set * createRangeSet(CSolver *, VarType type, uint64_t lowrange, uint64_t highrange);
+MutableSet * createMutableSet(CSolver *, VarType type);
 
-       void addItem(MutableSet * set, uint64_t element);
-       int64_t createUniqueItem(MutableSet * set);
+void addItem(CSolver *, MutableSet * set, uint64_t element);
+int64_t createUniqueItem(CSolver *, MutableSet * set);
 
-       Element * getElementVar(Set * set);
-       Constraint * getBooleanVar();
+Element * getElementVar(CSolver *, Set * set);
+Boolean * getBooleanVar(CSolver *);
 
-       Function * createFunctionOperator(enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Constraint * overflowstatus);
-       //Does Not Overflow
-       Function * createFunctionOperator(enum ArithOp op);
-       Predicate * createPredicateOperator(enum CompOp op, Set ** domain);
+Function * createFunctionOperator(CSolver *, enum ArithOp op, Set ** domain, Set * range, enum OverFlowBehavior overflowbehavior, Boolean * overflowstatus);
+//Does Not Overflow
+Function * createFunctionOperatorPure(CSolver *, enum ArithOp op);
+Predicate * createPredicateOperator(CSolver *, enum CompOp op, Set ** domain);
 
-       Table * createTable(Set **domains, Set * range);
-       void addTableEntry(Element ** inputs, Element *result);
-       Function * completeTable(struct Table *);
+Table * createTable(CSolver *, Set **domains, Set * range);
+void addTableEntry(CSolver *, Element ** inputs, Element *result);
+Function * completeTable(CSolver *, struct Table *);
 
-       Element * applyFunction(Function * function, Element ** array);
-       Constraint * applyPredicate(Predicate * predicate, Element ** inputs);
-       Constraint * applyLogicalOperation(enum LogicOp op, Constraint ** array);
+Element * applyFunction(CSolver *, Function * function, Element ** array);
+Boolean * applyPredicate(CSolver *, Predicate * predicate, Element ** inputs);
+Boolean * applyLogicalOperation(CSolver *, enum LogicOp op, Boolean ** array);
 
-       void addConstraint(Constraint * constraint);
+void addBoolean(CSolver *, Boolean * constraint);
 
-       Order * createOrder(enum OrderType type, Set * set);
-       Constraint * orderedConstraint(Order * order, uint64_t first, uint64_t second);
-private:
-       ModelVector<Constraint *> constraints;
-};
+Order * createOrder(CSolver *, enum OrderType type, Set * set);
+Boolean * orderConstraint(CSolver *, Order * order, uint64_t first, uint64_t second);
 #endif
index 2b9d1e1263a0f490b4b234dbab770c5845065cc6..e9284f79870c52f19db91445397a0e9b77b8cb14 100644 (file)
@@ -1,5 +1,7 @@
 #include "element.h"
 
-Element::Element(Set * s) :
-       set(s) {
+Element *allocElement(Set * s) {
+       Element * tmp=(Element *)ouralloc(sizeof(Element));
+       tmp->set=s;
+       return tmp;
 }
index 2c0d1f6a8a8b62b8aa176999d37ac4b27de87b0c..06c33a09849eb276a137007e4c325724e2d1f733 100644 (file)
@@ -3,11 +3,9 @@
 #include "classlist.h"
 #include "mymemory.h"
 
-class Element {
-public:
-       Element(Set *s);
-       MEMALLOC;
-private:
-       Set *set;
+struct Element {
+       Set * set;
 };
+
+Element * allocElement(Set *s);
 #endif
index 69abc541c16c64dc390f90a19898ea7b8c0866be..da5087b579e06373e3e25c193f2f37d79c5f77d2 100644 (file)
@@ -2,10 +2,7 @@
 #define FUNCTION_H
 #include "classlist.h"
 #include "mymemory.h"
-class Function {
-public:
 
-       MEMALLOC;
-private:
+struct Function {
 };
 #endif
index 76bb77979c05e90f52d914993312f3e4c415a578..3f33f9035b1f76ab62d1619a43a663d0466b3f99 100644 (file)
@@ -1,2 +1,3 @@
 #include "mutableset.h"
 
+void addElementMSet(MutableSet * set, uint64_t element) { pushVectorInt(set->members, element); }
index 479f16c8101e5fa5efc70907db6598e3b86bca08..eee89bbf3e47c725d8bee393a4e1b4c6f3ba400e 100644 (file)
@@ -2,8 +2,5 @@
 #define MUTABLESET_H
 #include "set.h"
 
-class MutableSet : Set {
-public:
-       void addElement(uint64_t element) { members->push_back(element); }
-};
+void addElementMSet(MutableSet * set, uint64_t element);
 #endif
index d55c1383b09e6b84482cae8329cbf55835aecb14..5267ce2327e2fd4fc2243f4bf274344b40bc8c36 100644 (file)
@@ -21,7 +21,8 @@
 
 /** MEMALLOC declares the allocators for a class to allocate
  *     memory in the non-snapshotting heap. */
-#define MEMALLOC \
+/*
+#define MEMALLOC                                                                                \
        void * operator new(size_t size) { \
                return model_malloc(size); \
        } \
        void * operator new(size_t size, void *p) {     \
                return p;                                                                                                                                                               \
        }
+*/
+
+void * ourmalloc(size_t size);
+void ourfree(void *ptr);
+void * ourcalloc(size_t count, size_t size);
+void * ourrealloc(void *ptr, size_t size);
 
 void *model_malloc(size_t size);
 void *model_calloc(size_t count, size_t size);
 void * model_realloc(void *ptr, size_t size);
 void model_free(void *ptr);
 
-/** @brief Provides a non-snapshotting allocator for use in STL classes.
- *
- * The code was adapted from a code example from the book The C++
- * Standard Library - A Tutorial and Reference by Nicolai M. Josuttis,
- * Addison-Wesley, 1999 © Copyright Nicolai M. Josuttis 1999
- * Permission to copy, use, modify, sell and distribute this software
- * is granted provided this copyright notice appears in all copies.
- * This software is provided "as is" without express or implied
- * warranty, and with no claim as to its suitability for any purpose.
- */
-template <class T>
-class ModelAlloc {
-public:
-       // type definitions
-       typedef T value_type;
-       typedef T*       pointer;
-       typedef const T* const_pointer;
-       typedef T&       reference;
-       typedef const T& const_reference;
-       typedef size_t size_type;
-       typedef size_t difference_type;
-
-       // rebind allocator to type U
-       template <class U>
-       struct rebind {
-               typedef ModelAlloc<U> other;
-       };
-
-       // return address of values
-       pointer address(reference value) const {
-               return &value;
-       }
-       const_pointer address(const_reference value) const {
-               return &value;
-       }
-
-       /* constructors and destructor
-        * - nothing to do because the allocator has no state
-        */
-       ModelAlloc() throw() {
-       }
-       ModelAlloc(const ModelAlloc&) throw() {
-       }
-       template <class U>
-       ModelAlloc(const ModelAlloc<U>&) throw() {
-       }
-       ~ModelAlloc() throw() {
-       }
-
-       // return maximum number of elements that can be allocated
-       size_type max_size() const throw() {
-               return std::numeric_limits<size_t>::max() / sizeof(T);
-       }
-
-       // allocate but don't initialize num elements of type T
-       pointer allocate(size_type num, const void * = 0) {
-               pointer p = (pointer)model_malloc(num * sizeof(T));
-               return p;
-       }
-
-       // initialize elements of allocated storage p with value value
-       void construct(pointer p, const T& value) {
-               // initialize memory with placement new
-               new((void*)p)T(value);
-       }
-
-       // destroy elements of initialized storage p
-       void destroy(pointer p) {
-               // destroy objects by calling their destructor
-               p->~T();
-       }
-
-       // deallocate storage p of deleted elements
-       void deallocate(pointer p, size_type num) {
-               model_free((void*)p);
-       }
-};
-
-/** Return that all specializations of this allocator are interchangeable. */
-template <class T1, class T2>
-bool operator ==(const ModelAlloc<T1>&,
-                                                                const ModelAlloc<T2>&) throw() {
-       return true;
-}
-
-/** Return that all specializations of this allocator are interchangeable. */
-template <class T1, class T2>
-bool operator!= (const ModelAlloc<T1>&,
-                                                                const ModelAlloc<T2>&) throw() {
-       return false;
-}
-
-
 #endif/* _MY_MEMORY_H */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..727b2dd3888d35a3bf45fd292a4a9142f2d7feba 100644 (file)
@@ -0,0 +1 @@
+#include "order.h"
index e40c879e31f2a67238bda2e782b97a80f7164f4d..b164a11bb651b5903ecf38faedf63d848702304a 100644 (file)
@@ -3,10 +3,6 @@
 #include "classlist.h"
 #include "mymemory.h"
 
-class Order {
-public:
-       MEMALLOC;
-
-private:
+struct Order {
 };
 #endif
index 3a79a9e353fdac58a28e1223d8105784857ad2e7..9a1766962392fc36c70c9a9427792481b204cd3e 100644 (file)
@@ -3,10 +3,7 @@
 #include "classlist.h"
 #include "mymemory.h"
 
-class Predicate {
-public:
+struct Predicate {
 
-       MEMALLOC;
-private:
 };
 #endif
index 043aece429927b38e4ee58ea731ea938fb9f108c..c92de333d41be63ed10d72aa4de861827f25f17f 100644 (file)
--- a/src/set.c
+++ b/src/set.c
@@ -1,27 +1,28 @@
 #include "set.h"
 #include <stddef.h>
-#include <cassert>
 
-Set::Set(VarType t, uint64_t* elements, int num) :
-       type (t),
-       isRange(false),
-       low(0),
-       high(0),
-       members(new ModelVector<uint64_t>()) {
-       members->reserve(num);
-       for(int i=0;i<num;i++)
-               members->push_back(elements[i]);
+Set * allocSet(VarType t, uint64_t* elements, uint num) {
+       Set * tmp=(Set *)ourmalloc(sizeof(struct Set));
+       tmp->type=t;
+       tmp->isRange=false;
+       tmp->low=0;
+       tmp->high=0;
+       tmp->members=allocVectorArrayInt(elements, num);
+       return tmp;
 }
 
-Set::Set(VarType t, uint64_t lowrange, uint64_t highrange) :
-       type(t),
-       isRange(true),
-       low(lowrange),
-       high(highrange),
-       members(NULL) {
+Set * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange) {
+       Set * tmp=(Set *)ourmalloc(sizeof(struct Set));
+       tmp->type=t;
+       tmp->isRange=true;
+       tmp->low=lowrange;
+       tmp->high=highrange;
+       tmp->members=NULL;
+       return tmp;
 }
 
-Set::~Set() {
-       if (isRange)
-               delete members;
+void freeSet(Set * set) {
+       if (set->isRange)
+               freeVectorInt(set->members);
+       ourfree(set);
 }
index 87992082357fe0259fe6719955ec81b02f7caa80..dee406676f296c52c5ab0751a07d218550cefbe3 100644 (file)
--- a/src/set.h
+++ b/src/set.h
@@ -9,23 +9,19 @@
 #define SET_H
 
 #include "classlist.h"
-#include "stl-model.h"
+#include "structs.h"
 #include "mymemory.h"
 
-class Set {
-public:
-       Set(VarType t, uint64_t * elements, int num);
-       Set(VarType t, uint64_t lowrange, uint64_t highrange);
-       ~Set();
-
-       MEMALLOC;
-private:
+struct Set {
        VarType type;
        bool isRange;
        uint64_t low, high;
-
-protected:
-       ModelVector<uint64_t> *members;
+       VectorInt * members;
 };
+
+
+Set *allocSet(VarType t, uint64_t * elements, uint num);
+Set    * allocSetRange(VarType t, uint64_t lowrange, uint64_t highrange);
+void freeSet(Set *set);
 #endif/* SET_H */
 
diff --git a/src/stl-model.h b/src/stl-model.h
deleted file mode 100644 (file)
index d3fd8c3..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*      Copyright (c) 2015 Regents of the University of California
- *
- *      Author: Brian Demsky <bdemsky@uci.edu>
- *
- *      This program is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU General Public License
- *      version 2 as published by the Free Software Foundation.
- */
-
-#ifndef __STL_MODEL_H__
-#define __STL_MODEL_H__
-
-#include <vector>
-#include <list>
-#include "mymemory.h"
-
-template<typename _Tp>
-class ModelList : public std::list<_Tp, ModelAlloc<_Tp> >
-{
-public:
-       typedef std::list< _Tp, ModelAlloc<_Tp> > list;
-
-       ModelList() :
-               list()
-       { }
-
-       ModelList(size_t n, const _Tp& val = _Tp()) :
-               list(n, val)
-       { }
-
-       MEMALLOC;
-};
-
-template<typename _Tp>
-class ModelVector : public std::vector<_Tp, ModelAlloc<_Tp> >
-{
-public:
-       typedef std::vector< _Tp, ModelAlloc<_Tp> > vector;
-
-       ModelVector() :
-               vector()
-       { }
-
-       ModelVector(size_t n, const _Tp& val = _Tp()) :
-               vector(n, val)
-       { }
-
-       MEMALLOC;
-};
-
-#endif/* __STL_MODEL_H__ */
diff --git a/src/structs.c b/src/structs.c
new file mode 100644 (file)
index 0000000..7eea923
--- /dev/null
@@ -0,0 +1,5 @@
+#include "structs.h"
+#include "mymemory.h"
+
+VectorImpl(Int, uint64_t, 4);
+VectorImpl(Boolean, Boolean *, 4);
diff --git a/src/structs.h b/src/structs.h
new file mode 100644 (file)
index 0000000..4229f71
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef STRUCTS_H
+#define STRUCTS_H
+#include "vector.h"
+#include "classlist.h"
+
+VectorDef(Int, uint64_t, 4);
+VectorDef(Boolean, Boolean *, 4);
+#endif
index f726c4ec1d3f1506c49a1c14d90ee61eb6a38edc..6e886b78100cbc18fa6c44c3c0b6be1672fcf4e4 100644 (file)
@@ -3,9 +3,9 @@
 #include "classlist.h"
 #include "mymemory.h"
 
-class Table {
-public:
-       MEMALLOC;
-private:
+struct Table {
+       
 };
+
+Table * allocTable();
 #endif
diff --git a/src/vector.h b/src/vector.h
new file mode 100644 (file)
index 0000000..e9a3361
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef VECTOR_H
+#define VECTOR_H
+#include <string.h>
+
+#define VectorDef(name, type, defcap)                                                                                                                                          \
+       struct Vector ## name {                                                                                                                                                                                         \
+               uint size;                                                                                                                                                                                                                                      \
+               uint capacity;                                                                                                                                                                                                                  \
+               type * array;                                                                                                                                                                                                                           \
+       };                                                                                                                                                                                                                                                                              \
+       typedef struct Vector ## name Vector ## name;                                                                                                   \
+       Vector ## name * allocVector ## name(uint capacity);                                                                    \
+       Vector ## name * allocDefVector ## name();                                                                                                              \
+       Vector ## name * allocVectorArray ## name(type * array, uint capacity); \
+       void pushVector ## name(Vector ## name *vector, type item);                                             \
+       type getVector ## name(Vector ## name *vector, uint index);                                             \
+       void setVector ## name(Vector ## name *vector, uint index, type item); \
+       uint getSize ##name(Vector ##name *vector);                                                                                                             \
+       void freeVector ##name(Vector ##name *vector);
+
+#define VectorImpl(name, type, defcap)                                                                                                                                 \
+       Vector ## name * allocDefVector ## name() {                                                                                                             \
+               return allocVector ## name(defcap);                                                                                                                                     \
+       }                                                                                                                                                                                                                                                                                       \
+       Vector ## name * allocVector ## name(uint capacity)     {                                                                       \
+               Vector ## name * tmp = (Vector ## name *) ourmalloc(sizeof(type));      \
+               tmp->size = 0;                                                                                                                                                                                                                  \
+               tmp->capacity = capacity;                                                                                                                                                                               \
+               tmp->array = (type *) ourcalloc(1, sizeof(type) * capacity);                                    \
+               return tmp;                                                                                                                                                                                                                                     \
+       }                                                                                                                                                                                                                                                                                       \
+       Vector ## name * allocVectorArray ## name(uint capacity, type * array)  {       \
+               Vector ## name * tmp = allocVector ## name(capacity);                                                           \
+               memcpy(tmp->array, array, capacity * sizeof(type));                                                                     \
+               return tmp;                                                                                                                                                                                                                                     \
+       }                                                                                                                                                                                                                                                                                       \
+       void pushVector ## name(Vector ## name *vector, type item) {                                    \
+               if (vector->size >= vector->capacity) {                                                                                                                 \
+                       uint newcap=vector->capacity * 2;                                                                                                                                       \
+                       vector->array=(type *)ourrealloc(vector->array, newcap);                                        \
+               }                                                                                                                                                                                                                                                                               \
+               vector->array[vector->size++] = item;                                                                                                                           \
+       }                                                                                                                                                                                                                                                                                       \
+       type getVector ## name(Vector ## name * vector, uint index) {                                   \
+               return vector->array[index];                                                                                                                                                            \
+       }                                                                                                                                                                                                                                                                                       \
+       void setVector ## name(Vector ## name * vector, uint index, type item) { \
+               vector->array[index]=item;                                                                                                                                                                      \
+       }                                                                                                                                                                                                                                                                                       \
+       uint getSize ## name(Vector ## name *vector) {                                                                                          \
+               return vector->size;                                                                                                                                                                                            \
+       }                                                                                                                                                                                                                                                                                       \
+       void freeVector ##name(Vector ##name *vector) {                                                                                         \
+               ourfree(vector->array);                                                                                                                                                                                 \
+               ourfree(vector);                                                                                                                                                                                                                \
+       }
+#endif