本文整理汇总了C++中MemoryAttr::reallocate方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryAttr::reallocate方法的具体用法?C++ MemoryAttr::reallocate怎么用?C++ MemoryAttr::reallocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryAttr
的用法示例。
在下文中一共展示了MemoryAttr::reallocate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
virtual int run()
{
MemoryAttr buf;
const size32_t incSize = 512;
size32_t bufferSize = 0;
char * buffer = NULL;
size_t remaining = 0;
bool eof = false;
while (!eof)
{
if (remaining == bufferSize)
{
bufferSize += incSize;
buffer = (char *) buf.reallocate(bufferSize);
}
size32_t read = pipe->readError(bufferSize-remaining, buffer+remaining);
if ((read == 0) || (read == (size32_t)-1))
eof = true;
else
remaining += read;
char *finger = buffer;
while (remaining)
{
char *eolpos = (char *) memchr(finger, '\n', remaining);
if (eolpos)
{
*eolpos = '\0';
if (eolpos > finger && eolpos[-1]=='\r')
eolpos[-1] = '\0';
if (errorReporter)
errorReporter->reportError(finger, 0);
else
DBGLOG("%s", finger);
errors++;
remaining -= (eolpos-finger) + 1;
finger = eolpos + 1;
}
else if (eof)
{
StringBuffer e(remaining, finger);
if (errorReporter)
errorReporter->reportError(e, 0);
else
DBGLOG("%s", e.str());
errors++;
break;
}
else
break;
}
if (!eof && (finger != buffer))
memmove(buffer, finger, remaining);
}
return 0;
}