| 138 | } |
| 139 | |
| 140 | char* VArenaAlloc::allocObjectWithFooter(uint32_t sizeIncludingFooter, uint32_t alignment) { |
| 141 | uintptr_t mask = alignment - 1; |
| 142 | |
| 143 | restart: |
| 144 | uint32_t skipOverhead = 0; |
| 145 | bool needsSkipFooter = fCursor != fDtorCursor; |
| 146 | if (needsSkipFooter) { |
| 147 | skipOverhead = sizeof(Footer) + sizeof(uint32_t); |
| 148 | } |
| 149 | char* objStart = (char*)((uintptr_t)(fCursor + skipOverhead + mask) & ~mask); |
| 150 | uint32_t totalSize = sizeIncludingFooter + skipOverhead; |
| 151 | //std::cout<<"non POD object size = "<<totalSize<<"\n"; |
| 152 | if ((ptrdiff_t)totalSize > fEnd - objStart) { |
| 153 | this->ensureSpace(totalSize, alignment); |
| 154 | goto restart; |
| 155 | } |
| 156 | |
| 157 | AssertRelease((ptrdiff_t)totalSize <= fEnd - objStart); |
| 158 | |
| 159 | // Install a skip footer if needed, thus terminating a run of POD data. The calling code is |
| 160 | // responsible for installing the footer after the object. |
| 161 | if (needsSkipFooter) { |
| 162 | this->installUint32Footer(SkipPod, ToU32(fCursor - fDtorCursor), 0); |
| 163 | } |
| 164 | |
| 165 | return objStart; |
| 166 | } |
no test coverage detected