MCPcopy Create free account
hub / github.com/cisco/openh264 / WelsMalloc

Function WelsMalloc

codec/processing/src/common/memory.cpp:35–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#include "memory.h"
34
35WELSVP_NAMESPACE_BEGIN
36/////////////////////////////////////////////////////////////////////////////////
37
38void* WelsMalloc (const uint32_t kuiSize, char* pTag) {
39 const int32_t kiSizeVoidPointer = sizeof (void**);
40 const int32_t kiSizeInt32 = sizeof (int32_t);
41 const int32_t kiAlignedBytes = ALIGNBYTES - 1;
42
43 uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32);
44 uint8_t* pAlignedBuf = NULL;
45
46 if (NULL == pBuf)
47 return NULL;
48
49 // to fill zero values
50 WelsMemset (pBuf, 0, kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32);
51
52 pAlignedBuf = pBuf + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32;
53 pAlignedBuf -= WelsCastFromPointer (pAlignedBuf) & kiAlignedBytes;
54 * ((void**) (pAlignedBuf - kiSizeVoidPointer)) = pBuf;
55 * ((int32_t*) (pAlignedBuf - (kiSizeVoidPointer + kiSizeInt32))) = kuiSize;
56
57 return (pAlignedBuf);
58}
59
60/////////////////////////////////////////////////////////////////////////////
61

Callers 3

InternalReallocateFunction · 0.70
AllocateSampleBufferMethod · 0.50
AllocateOUArrayMemoryMethod · 0.50

Calls 1

WelsMemsetFunction · 0.70

Tested by

no test coverage detected