Removed the archive-making rule + cosmetics.
[svrt.git] / misc.h
diff --git a/misc.h b/misc.h
index e3dbab2..e101861 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -82,4 +82,16 @@ inline scalar_t log2(scalar_t x) {
   return log(x)/log(2.0);
 }
 
+template <class T>
+void grow(int *nb_max, int nb, T** current, int factor) {
+  ASSERT(*nb_max > 0);
+  if(nb == *nb_max) {
+    T *tmp = new T[*nb_max * factor];
+    memcpy(tmp, *current, *nb_max * sizeof(T));
+    delete[] *current;
+    *current = tmp;
+    *nb_max *= factor;
+  }
+}
+
 #endif