string& string::operator=(const TinySTL::string &str){ if(this != &str){ destroyAndDeallocate(); allocateAndCopy(str.start_, str.finish_); } return *this; }
void CLabel::set(const void* Str){ width((int)strlen((const char*)Str)); //deallocates the dynamic memory where the label's data has been stored delete [] (char*)pdata(); //allocates dynamic memory for that data and copies the data in the newly allocated memory allocateAndCopy((const char*)Str); }
CLine::CLine(int Row, int Col, int Width, int Maxdatalen, bool* Insertmode, bool Bordered, const char* Border): CField (Row, Col, Width, Bordered ? 3 : 1, NULL, Bordered, Border) { cursor=0; offset=0; _maxDatalen=Maxdatalen; //_insMode=Insertmode; allocateAndCopy(""); }
void BigUnsigned::setBlock(Index i, Blk newBlock) { if (newBlock == 0) { if (i < len) { blk[i] = 0; zapLeadingZeros(); } // If i >= len, no effect. } else { if (i >= len) { // The nonzero block extends the number. allocateAndCopy(i+1); // Zero any added blocks that we aren't setting. for (Index j = len; j < i; j++) blk[j] = 0; len = i+1; } blk[i] = newBlock; } }
void CLine::set(const void* Str) { if(alloc) delete [] (char*)pdata(); allocateAndCopy((const char*)Str); }
CLabel::CLabel(int Row, int Col, int Len) : CField(Row,Col,Len){ allocateAndCopy(""); }
CLabel::CLabel(const char *Str, int Row, int Col, int Len) : CField(Row,Col,Len==-1?strlen(Str):Len){ allocateAndCopy(Str); }
//A copy constructor which copies the source object's data //into the dynamic memory that stores the label's data CLabel::CLabel(const CLabel& L):CField(L){ allocateAndCopy((char*)L.pdata()); }
string::string(const string &str, size_t pos, size_t len){ len = changeVarWhenEuqalNPOS(len, str.size(), pos); allocateAndCopy(str.start_ + pos, str.start_ + pos + len); }
string& string::operator=(const char *s){ destroyAndDeallocate(); allocateAndCopy(s, s+strlen(s)); return *this; }
string::string(const char* s, size_t n){ allocateAndCopy(s, s+n); }
string::string(const char* s){ allocateAndCopy(s, s + strlen(s)); }
string::string(const string& str) { allocateAndCopy(str.start_, str.finish_); }