CMyString& CMyString::Append(const char *pszName) { int nLength = strlen(pszName) + m_nLength; //空间不够 if (nLength >= m_nSize) { //申请新空间 char *lpNewBuff = AllocBuff(nLength + 1); //拷贝旧的数据 strcpy(lpNewBuff, m_pBuff); //释放旧空间 FreeBuff(); m_pBuff = lpNewBuff; m_nSize = nLength + 1; } if (m_pBuff != NULL) strcat(m_pBuff, pszName); m_nLength = nLength; return *this; }
bool TYPBLK<TYPE>::Init(PGLOBAL g, bool check) { if (!Blkp) if (AllocBuff(g, Nval * sizeof(TYPE))) return true; Check = check; Global = g; return false; } // end of Init
bool STRBLK::Init(PGLOBAL g, bool check) { if (!Blkp) if (AllocBuff(g, Nval * sizeof(PSZ))) return true; Check = check; Global = g; return false; } // end of Init
bool CHRBLK::Init(PGLOBAL g, bool check) { Valp = (char*)PlugSubAlloc(g, NULL, Long + 1); Valp[Long] = '\0'; if (!Blkp) if (AllocBuff(g, Nval * Long)) return true; Check = check; Global = g; return false; } // end of Init
CMyString& CMyString::SetString(const char *pszName) { int nLength = strlen(pszName); //空间不够 if (nLength >= m_nSize) { //释放旧空间 FreeBuff(); //申请新空间 m_pBuff = AllocBuff(nLength + 1); m_nSize = nLength + 1; } if (m_pBuff != NULL) strcpy(m_pBuff, pszName); m_nLength = nLength; return *this; }