MCPcopy Create free account
hub / github.com/beefytech/Beef / Alloc

Method Alloc

BeefySysLib/util/BeefPerf.cpp:121–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121uint8* Buffer::Alloc(int size)
122{
123 if (mDataSize + size > mBufSize)
124 {
125 // Grow factor 50%
126 int wantSize = max(mDataSize + size, mBufSize + mBufSize / 2);
127 auto bpManager = BpManager::Get();
128 //uint8* newPtr = new uint8[wantSize];
129 uint8* newPtr = (uint8*)bpManager->AllocBytes(wantSize);
130 memcpy(newPtr, mPtr, mDataSize);
131 //delete mPtr;
132 bpManager->FreeBytes(mPtr);
133 mPtr = newPtr;
134 mBufSize = wantSize;
135 }
136 uint8* ptr = mPtr + mDataSize;
137 mDataSize += size;
138 return ptr;
139}
140
141void Buffer::Free()
142{

Callers 1

ThreadProcMethod · 0.45

Calls 3

GetFunction · 0.85
FreeBytesMethod · 0.80
AllocBytesMethod · 0.45

Tested by

no test coverage detected