X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=misc.h;h=4762eaa19c44ba98c49e9e988ebf226242f3ad4b;hb=d34ac2b649f3f88ffae5d52f36e1d86b75791d39;hp=e3dbab2e577485ebbab2a6a48f54c47a3f75c7c3;hpb=4cbdf193cd4e79a68e10a651825d089369e6214d;p=svrt.git
diff --git a/misc.h b/misc.h
index e3dbab2..4762eaa 100644
--- a/misc.h
+++ b/misc.h
@@ -18,7 +18,7 @@
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with selector. If not, see .
+ * along with svrt. If not, see .
*
*/
@@ -82,4 +82,16 @@ inline scalar_t log2(scalar_t x) {
return log(x)/log(2.0);
}
+template
+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