MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / add

Method add

physx/source/common/src/CmPtrTable.cpp:114–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void PtrTable::add(void* ptr, PtrTableStorageManager& sm)
115{
116 if(mCount == 0) // 0 -> 1, easy case
117 {
118 PX_ASSERT(mOwnsMemory);
119 PX_ASSERT(mList == NULL);
120 PX_ASSERT(!mBufferUsed);
121 mSingle = ptr;
122 mCount = 1;
123 mBufferUsed = true;
124 return;
125 }
126
127 if(mCount == 1) // 1 -> 2, easy case
128 {
129 PX_ASSERT(mOwnsMemory);
130 PX_ASSERT(mBufferUsed);
131
132 void* single = mSingle;
133 mList = sm.allocate(2*sizeof(void*));
134 mList[0] = single;
135 mBufferUsed = false;
136 mOwnsMemory = true;
137 }
138 else
139 {
140 PX_ASSERT(!mBufferUsed);
141
142 if(!mOwnsMemory) // don't own the memory, must always alloc
143 realloc(0, Ps::nextPowerOfTwo(mCount), sm); // we're guaranteed nextPowerOfTwo(x) > x
144
145 else if(Ps::isPowerOfTwo(mCount)) // count is at implicit capacity, so realloc
146 realloc(mCount, PxU32(mCount)*2, sm); // ... to next higher power of 2
147
148 PX_ASSERT(mOwnsMemory);
149 }
150
151 mList[mCount++] = ptr;
152}
153
154void PtrTable::replaceWithLast(PxU32 index, PtrTableStorageManager& sm)
155{

Callers 15

createCollectionsFunction · 0.45
generateExampleFilesFunction · 0.45
generateExampleFileFunction · 0.45
addWindMillsMethod · 0.45
createChunkMethod · 0.45
serializeMethod · 0.45
loadChunkMethod · 0.45
MeshBuilderMethod · 0.45
addRepXToPxCollectionMethod · 0.45
saveMethod · 0.45

Calls 3

nextPowerOfTwoFunction · 0.85
isPowerOfTwoFunction · 0.85
allocateMethod · 0.45

Tested by

no test coverage detected