Skip to content

Commit 33c2e43

Browse files
Morel BérengerVReaperV
authored andcommitted
recvmsg: use malloc instead of new, reduces a tiny bit time spent there
1 parent ebefb25 commit 33c2e43

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/common/IPC/Primitives.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,12 @@ bool InternalRecvMsg(Sys::OSHandle handle, Util::Reader& reader)
340340
NaClIOVec iov[2];
341341
NaClHandle h[NACL_ABI_IMC_DESC_MAX];
342342
if (!recvBuffer) {
343-
recvBuffer.reset(new char[NACL_ABI_IMC_BYTES_MAX]);
343+
//while using malloc in combination with delete[] or delete is
344+
//a bad idea in theory, in this case, we are freeing an array of
345+
//bytes, there is NOTHING special to clean in a string of bytes.
346+
//This does, however, avoid new[] or new to initilialise data,
347+
//those functions being actually closer to calloc than malloc.
348+
recvBuffer.reset( static_cast<char*>( malloc( NACL_ABI_IMC_BYTES_MAX ) ) );
344349
}
345350

346351
std::fill(std::begin(h), std::end(h),NACL_INVALID_HANDLE)

0 commit comments

Comments
 (0)