2010.8.12 CString最大可以多大?
void CString::AllocBuffer(int nLen)
{
assert(nLen >= 0);
assert(nLen <= 2147483647-1); // (signed) int 的最大值 2G
if (nLen == 0)
Init();
else
{
CStringData* pData;
{
pData = (CStringData*)
new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
pData->nAllocLength = nLen;
}
pData->nRefs = 1;
pData->data()[nLen] = '\0';
pData->nDataLength = nLen;
m_pchData = pData->data();
}
}
{
assert(nLen >= 0);
assert(nLen <= 2147483647-1); // (signed) int 的最大值 2G
if (nLen == 0)
Init();
else
{
CStringData* pData;
{
pData = (CStringData*)
new BYTE[sizeof(CStringData) + (nLen+1)*sizeof(TCHAR)];
pData->nAllocLength = nLen;
}
pData->nRefs = 1;
pData->data()[nLen] = '\0';
pData->nDataLength = nLen;
m_pchData = pData->data();
}
}
以上是CString的源代码,可以看出最大可以分配2G的内存,所以处理的最大数据量为2G了,并不是无限大。