Logo Search packages:      
Sourcecode: pwlib version File versions

BOOL PString::SetSize ( PINDEX  newSize  )  [virtual, inherited]

Set the size of the string. A new string may be allocated to accomodate the new number of characters. If the string increases in size then the new characters are initialised to zero. If the string is made smaller then the data beyond the new size is lost.

Note that this function will break the current instance from multiple references to an array. A new array is allocated and the data from the old array copied to it.

TRUE if the memory for the array was allocated successfully.
newSize  New size of the array in elements.

Definition at line 1607 of file contain.cxx.

References PAbstractArray::SetSize().

Referenced by PFTPClient::GetDirectoryNames(), PHTTPResource::LoadData(), PString::MakeEmpty(), PString::MakeMinimumSize(), PString::MakeUnique(), PString::operator &(), PString::operator &=(), PString::operator+(), PString::operator+=(), PString::PString(), PHTTPServer::ReadEntityBody(), PString::ReadFrom(), PChannel::ReadString(), PString::Splice(), and PString::vsprintf().

  return PAbstractArray::SetSize(newSize);
#if 0
  if (IsUnique())
    return PAbstractArray::SetSize(newSize);

  PINDEX newsizebytes = elementSize*newSize;
  PINDEX oldsizebytes = elementSize*GetSize();
  char * newArray;

  if (newsizebytes == 0)
    newArray = NULL;
  else {
    if ((newArray = (char *)malloc(newsizebytes)) == NULL)
      return FALSE;

    if (theArray != NULL)
      memcpy(newArray, theArray, PMIN(oldsizebytes, newsizebytes));

  reference = new Reference(newSize);

  if (newsizebytes > oldsizebytes)
    memset(newArray+oldsizebytes, 0, newsizebytes-oldsizebytes);

  theArray = newArray;
  return TRUE;

Generated by  Doxygen 1.6.0   Back to index