Logo Search packages:      
Sourcecode: condor version File versions  Download package

bool MyString::reserve_at_least ( const int  sz  ) 

This is like calling malloc, but more interesting: it makes sure the capacity of the string is at least sz bytes, and preferably twice sz bytes. It copies whatever is in the string into the memory. It will truncate the string if you decrease the size. You don't normally need to call this--it's used to make appending to a string more efficient.

Definition at line 190 of file MyString.cpp.

References reserve().

Referenced by operator+=(), and vsprintf_cat().

{
      int twice_as_much;
      bool success;

      twice_as_much = 2 * capacity;
      if (twice_as_much > sz) {
            success = reserve(twice_as_much);
            if (!success) { // allocate failed, get just enough?
                  success = reserve(sz);
            }
      } else {
            success = reserve(sz);
      }
      return success;
}


Generated by  Doxygen 1.6.0   Back to index