Browse Source

Replace calls to ALLOC() macro with malloc.

Darryl Pogue 13 years ago committed by Adam Johnson
parent
commit
3c5ed83020
  1. 2
      Sources/Plasma/CoreLib/hsMalloc.h
  2. 4
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  3. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp
  4. 8
      Sources/Plasma/NucleusLib/pnIni/Private/pnIniCore.cpp
  5. 2
      Sources/Plasma/NucleusLib/pnMail/pnMail.cpp
  6. 2
      Sources/Plasma/NucleusLib/pnNetDiag/pnNetSys.cpp
  7. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.cpp
  8. 2
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/pnNpCommon.h
  9. 2
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCmd.cpp
  10. 2
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h
  11. 8
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp

2
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

4
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;

2
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])

8
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) {

2
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;

2
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;

4
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;
}

2
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

2
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:

2
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtSkipList.h

@ -166,7 +166,7 @@ template<class T, class K, unsigned keyOffset, class Cmp>
typename TSkipList<T,K,keyOffset,Cmp>::Node* TSkipList<T,K,keyOffset,Cmp>::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;
}

8
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtStr.cpp

@ -75,7 +75,7 @@ static uint32_t s_hashValue[] = {
template<class chartype>
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;
}

Loading…
Cancel
Save