MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / VectorResize

Function VectorResize

Engine/source/core/util/tVector.cpp:31–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29#ifdef TORQUE_DEBUG_GUARD
30
31bool VectorResize(U32 *aSize, U32 *aCount, void **arrayPtr, U32 newCount, U32 elemSize,
32 const char* fileName,
33 const U32 lineNum)
34{
35 PROFILE_SCOPE( VectorResize );
36
37 if (newCount > 0)
38 {
39 U32 blocks = newCount / VectorBlockSize;
40 if (newCount % VectorBlockSize)
41 blocks++;
42 S32 mem_size = blocks * VectorBlockSize * elemSize;
43
44 const char* pUseFileName = fileName != NULL ? fileName : __FILE__;
45 U32 useLineNum = fileName != NULL ? lineNum : __LINE__;
46
47 if (*arrayPtr != NULL)
48 *arrayPtr = dRealloc_r(*arrayPtr, mem_size, pUseFileName, useLineNum);
49 else
50 *arrayPtr = dMalloc_r(mem_size, pUseFileName, useLineNum);
51
52 AssertFatal( *arrayPtr, "VectorResize - Allocation failed." );
53
54 *aCount = newCount;
55 *aSize = blocks * VectorBlockSize;
56 return true;
57 }
58
59 if (*arrayPtr)
60 {
61 dFree(*arrayPtr);
62 *arrayPtr = 0;
63 }
64
65 *aSize = 0;
66 *aCount = 0;
67 return true;
68}
69
70#else
71

Callers 1

resizeMethod · 0.85

Calls 3

dRealloc_rFunction · 0.85
dMalloc_rFunction · 0.85
dFreeFunction · 0.50

Tested by

no test coverage detected