This may be a naive question, but what are the dangers of the following code (allocate more memory in the new operator for the info struct)?
struct Info
{
Info():nLineNo(0){memset(cFile, 0, 256);}
~Info(){}
char cFile[256];
unsigned int nLineNo;
};
void *operator new(size_t Size, const char *pcFile, const unsigned int nLine)
{
Info *pData = 0;
pData = (Info*)malloc(Size + sizeof(Info));
strcpy(pData->cFile, pcFile);
pData->nLineNo = nLine;
return (void*)pData;
}
void operator delete(void *pData)
{
Info *pInfo = (Info*)pData;
// could use pInfo->nLineNo to check for it within hash table of allocated blocks - just an example
free(pData);
}