Mercurial > hg > octave-lyh
diff src/utils.cc @ 244:d66cc97f77a9
[project @ 1993-12-03 01:30:19 by jwe]
author | jwe |
---|---|
date | Fri, 03 Dec 1993 01:30:19 +0000 |
parents | a99f28f5e351 |
children | c2189d67a05c |
line wrap: on
line diff
--- a/src/utils.cc +++ b/src/utils.cc @@ -362,17 +362,11 @@ } } -// Why do I have to do this? - char **foo = path; while (foo && *foo) - { - delete [] *foo; - *foo = (char *) NULL; - foo++; - } - + delete [] *foo++; delete [] path; + path = new char * [nelem+1]; path[nelem] = (char *) NULL; @@ -1313,11 +1307,17 @@ if (i == num_max - 1) { +// Reallocate the array. Only copy pointers, not the strings they +// point to, then only delete the original array of pointers, and not +// the strings they point to. + num_max += 256; char **tmp = new char * [num_max]; for (int j = 0; j < i; j++) tmp[j] = retval[j]; + delete [] retval; + retval = tmp; } } @@ -1350,11 +1350,17 @@ if (i + tmp_num >= num_max - 1) { +// Reallocate the array. Only copy pointers, not the strings they +// point to, then only delete the original array of pointers, and not +// the strings they point to. + num_max += 1024; char **tmp = new char * [num_max]; for (int j = 0; j < i; j++) tmp[j] = retval[j]; + delete [] retval; + retval = tmp; }