From 3c5ed8302044fdf33a70b43c84d07040b31ffd8c Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Fri, 20 Jan 2012 23:30:32 -0800 Subject: [PATCH] Replace calls to ALLOC() macro with malloc. --- Sources/Plasma/CoreLib/hsMalloc.h | 2 -- .../pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp | 4 ++-- Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp | 2 +- Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp | 8 ++++---- Sources/Plasma/NucleusLib/pnMail/pnMail.cpp | 2 +- Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp | 2 +- .../NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp | 4 ++-- .../Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h | 2 +- Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp | 2 +- Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h | 2 +- Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp | 8 ++++---- 11 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Sources/Plasma/CoreLib/hsMalloc.h b/Sources/Plasma/CoreLib/hsMalloc.h index f60cc0b1..643e7a84 100644 --- a/Sources/Plasma/CoreLib/hsMalloc.h +++ b/Sources/Plasma/CoreLib/hsMalloc.h @@ -164,7 +164,6 @@ inline void CDECL operator delete (void *, void *) {} * ***/ -#define ALLOC(b) MemAlloc(b, 0, __FILE__, __LINE__) #define ALLOCZERO(b) MemAlloc(b, kMemZero, __FILE__, __LINE__) #define ZERO(s) MemSet(&s, 0, sizeof(s)) #define ZEROPTR(p) MemSet(p, 0, sizeof(*p)) @@ -173,7 +172,6 @@ inline void CDECL operator delete (void *, void *) {} #ifdef __cplusplus #define NEW(t) new(MemAlloc(sizeof(t), 0, __FILE__, __LINE__)) t -#define NEWFLAGS(t, f) new(MemAlloc(sizeof(t), (f), __FILE__, __LINE__)) t #define NEWZERO(t) new(MemAlloc(sizeof(t), kMemZero, __FILE__, __LINE__)) t #endif // __cplusplus diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp index 094864de..e2c28dd2 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp @@ -348,7 +348,7 @@ static NtOpSocketWrite * SocketQueueAsyncWrite ( // extra space in case more data needs to be queued later unsigned bytesAlloc = max(bytes, sock->backlogAlloc); bytesAlloc = max(bytesAlloc, kMinBacklogBytes); - NtOpSocketWrite * op = new(ALLOC(sizeof(NtOpSocketWrite) + bytesAlloc)) NtOpSocketWrite; + NtOpSocketWrite * op = new(malloc(sizeof(NtOpSocketWrite) + bytesAlloc)) NtOpSocketWrite; // init Operation const AsyncId asyncId = INtConnSequenceStart(sock); @@ -1188,7 +1188,7 @@ void NtSocketConnect ( // create async connection record with enough extra bytes for sendData NtOpConnAttempt * op = - new(ALLOC(sizeof(NtOpConnAttempt) - sizeof(op->sendData) + sendBytes)) NtOpConnAttempt; + new(malloc(sizeof(NtOpConnAttempt) - sizeof(op->sendData) + sendBytes)) NtOpConnAttempt; // init Operation op->overlapped.Offset = 0; diff --git a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp index 8266236b..7fd10656 100644 --- a/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp +++ b/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp @@ -161,7 +161,7 @@ static void LogFileNotifyProc ( //============================================================================ static void AllocLogBuffer_CS (unsigned index) { ASSERT(!s_logBuf[index]); - s_logBuf[index] = (char *)ALLOC(s_logSize[index]); + s_logBuf[index] = (char *)malloc(s_logSize[index]); s_logPos[index] = 0; if (!s_logBuf[index]) diff --git a/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp b/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp index 017ce677..23e1af62 100644 --- a/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp +++ b/Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp @@ -150,7 +150,7 @@ static IniValue * AddKeyValue ( // Find or create the key IniKey * key = section->fKeys.Find(string); if (!key) { - key = new(ALLOC( + key = new(malloc( sizeof(*key) - sizeof(key->fName) + StrBytes(string) )) IniKey(section, string); } @@ -194,7 +194,7 @@ static IniSection * AddSection ( // Find or create the section IniSection * section = ini->fSections.Find(string); if (!section) { - section = new(ALLOC( + section = new(malloc( sizeof(*section) - sizeof(section->fName) + StrBytes(string) )) IniSection(string); ini->fSections.Add(section); @@ -405,7 +405,7 @@ static bool ParseFile ( } else { // Read entire file into memory and NULL terminate wchar_t - uint8_t * buffer = (uint8_t *) ALLOC((unsigned) fileSize + sizeof(wchar_t)); + uint8_t * buffer = (uint8_t *) malloc((unsigned) fileSize + sizeof(wchar_t)); AsyncFileRead(file, 0, buffer, (unsigned) fileSize, kAsyncFileRwSync, nil); * (wchar_t *) &buffer[fileSize] = 0; @@ -416,7 +416,7 @@ static bool ParseFile ( unsigned newBufferSize = ((unsigned) fileSize + 2) * sizeof(wchar_t); // Allocate new buffer - wchar_t * dst = (wchar_t *) ALLOC(newBufferSize); + wchar_t * dst = (wchar_t *) malloc(newBufferSize); // If it's UTF-8 file,convert to Unicode if (StrCmpI((char *)buffer, UTF8_BOM, StrLen(UTF8_BOM)) == 0) { diff --git a/Sources/Plasma/NucleusLib/pnMail/pnMail.cpp b/Sources/Plasma/NucleusLib/pnMail/pnMail.cpp index 2e93b43c..30a36f4a 100644 --- a/Sources/Plasma/NucleusLib/pnMail/pnMail.cpp +++ b/Sources/Plasma/NucleusLib/pnMail/pnMail.cpp @@ -514,7 +514,7 @@ static void IMail ( // Create a transaction record MailTransaction * transaction = new( - ALLOC(offsetof(MailTransaction, buffer) + bytes) + malloc(offsetof(MailTransaction, buffer) + bytes) ) MailTransaction; transaction->stepTable = stepTable; transaction->sock = nil; diff --git a/Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp b/Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp index cc9a4fce..dc96362a 100644 --- a/Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp +++ b/Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp @@ -158,7 +158,7 @@ void NetDiagSys ( ULONG ulOutBufLen = 0; GetAdaptersInfo(nil, &ulOutBufLen); - PIP_ADAPTER_INFO pInfo = (PIP_ADAPTER_INFO)ALLOC(ulOutBufLen); + PIP_ADAPTER_INFO pInfo = (PIP_ADAPTER_INFO)malloc(ulOutBufLen); PIP_ADAPTER_INFO pAdapter; if (GetAdaptersInfo(pInfo, &ulOutBufLen) == NO_ERROR) { pAdapter = pInfo; diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp index d8831588..404b7988 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp @@ -90,7 +90,7 @@ static inline void IReadArray (T ** buf, unsigned * elems, uint8_t ** buffer, un *elems = bytes / sizeof(T); T * src = (T *)*buffer; delete *buf; - *buf = (T *)ALLOC(bytes); + *buf = (T *)malloc(bytes); MemCopy(*buf, src, bytes); *buffer += bytes; *bufsz -= bytes; @@ -1100,7 +1100,7 @@ NetVaultNodeFieldArray::ESqlType NetVaultNodeFieldArray::GetSqlType_LCS (uint64_ //============================================================================ CSrvPackBuffer::CSrvPackBuffer (unsigned bytes) { - m_data = (uint8_t *)ALLOC(bytes); + m_data = (uint8_t *)malloc(bytes); m_pos = m_data; m_end = m_pos + bytes; } diff --git a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h index d14bb3a0..7666945d 100644 --- a/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h +++ b/Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h @@ -456,7 +456,7 @@ struct NetVaultNodeRef { // Allocate a CSrvPackBuffer on the heap with one extra uint32_t to allow for padding #define SRV_ALLOC_BUFFER(bytes) \ - new(ALLOC(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \ + new(malloc(sizeof(CSrvPackBuffer) + (bytes) + sizeof(uint32_t))) \ CSrvPackBuffer(bytes + sizeof(uint32_t)) // Allocate a CSrvPackBuffer on the stack with one extra uint32_t to allow for padding diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp index af502188..d4ce91f2 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp @@ -192,7 +192,7 @@ void CICmdParser::Error (const CmdTokState * state, ECmdError errorCode, const w // don't want to compose their own text. Normally, an application would // compose error text using its own localized strings.) unsigned chars = 256 + (arg ? StrLen(arg) : 0) + (value ? StrLen(value) : 0); - wchar_t * buffer = (wchar_t *)ALLOC(chars * sizeof(wchar_t)); + wchar_t * buffer = (wchar_t *)malloc(chars * sizeof(wchar_t)); switch (errorCode) { case kCmdErrorInvalidArg: diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h index 19bbc38c..df4668dd 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h @@ -166,7 +166,7 @@ template typename TSkipList::Node* TSkipList::AllocNode (unsigned level) { unsigned size = offsetof(Node, next) + (level + 1) * sizeof(Node); - Node * node = (Node *)ALLOC(size); + Node * node = (Node *)malloc(size); node->level = level; return node; } diff --git a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp index d51b4b0c..d75b6d7b 100644 --- a/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp +++ b/Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp @@ -75,7 +75,7 @@ static uint32_t s_hashValue[] = { template static chartype * IStrDup (const chartype str[]) { unsigned chars = IStrLen(str) + 1; - chartype * buffer = (chartype *)ALLOC(chars * sizeof(chartype)); + chartype * buffer = (chartype *)malloc(chars * sizeof(chartype)); IStrCopy(buffer, str, chars); return buffer; } @@ -86,7 +86,7 @@ static chartype * IStrDupLen (const chartype str[], unsigned chars) { unsigned len = IStrLen(str) + 1; if (len > chars) len = chars; - chartype * buffer = (chartype *)ALLOC(len * sizeof(chartype)); + chartype * buffer = (chartype *)malloc(len * sizeof(chartype)); IStrCopy(buffer, str, len); return buffer; } @@ -455,7 +455,7 @@ wchar_t * StrDupLen (const wchar_t str[], unsigned chars) { //============================================================================ wchar_t * StrDupToUnicode (const char str[]) { unsigned bytes = StrBytes(str) * sizeof(wchar_t); - wchar_t * dst = (wchar_t*)ALLOC(bytes); + wchar_t * dst = (wchar_t*)malloc(bytes); StrToUnicode(dst, str, bytes / sizeof(wchar_t)); return dst; } @@ -463,7 +463,7 @@ wchar_t * StrDupToUnicode (const char str[]) { //============================================================================ char * StrDupToAnsi (const wchar_t str[]) { unsigned bytes = StrBytes(str) / sizeof(wchar_t); - char * dst = (char*)ALLOC(bytes); + char * dst = (char*)malloc(bytes); StrToAnsi(dst, str, bytes); return dst; }