ns-allinone-2.35/ns-2.35/lib/int.Vec.cc
void intVec::resize(int newl)
{
  int* news = new int [newl];
  int* p = news;
  int minl = (len < newl)? len : newl;
  int* top = &(s[minl]);
  int* t = s;
  while (t < top) *p++ = *t++;
  delete [] s;
  s = news;
  len = newl;
}
// can't just realloc since there may be need for constructors/destructors
can't just realloc since there may be need for constructors/destructors
can ' t just realloc since there may be need for constructors / destructors
void intVec::resize(int newl)
{
  int* news = new int [newl];
  int* p = news;
  int minl = (len < newl)? len : newl;
  int* top = &(s[minl]);
  int* t = s;
  while (t < top) *p++ = *t++;
  delete [] s;
  s = news;
  len = newl;
}
void intVec :: resize ( int newl ) { int * news = new int [ newl ] ; int * p = news ; int minl = ( len < newl ) ? len : newl ; int * top = & ( s [ minl ] ) ; int * t = s ; while ( t < top ) * p ++ = * t ++ ; delete [ ] s ; s = news ; len = newl ; }
can't just realloc since there may be need for constructors/destructors
can ' t just realloc since there may be need for constructors / destructors