X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=svrt.git;a=blobdiff_plain;f=misc.h;h=4762eaa19c44ba98c49e9e988ebf226242f3ad4b;hp=e3dbab2e577485ebbab2a6a48f54c47a3f75c7c3;hb=HEAD;hpb=4cbdf193cd4e79a68e10a651825d089369e6214d;ds=sidebyside 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