| 119 | } |
| 120 | |
| 121 | uint8* 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 | |
| 141 | void Buffer::Free() |
| 142 | { |
no test coverage detected