| 188 | } |
| 189 | |
| 190 | char * MemoryModel::reallocate ( char * ptr, uint64_t size, uint64_t nsize ) { |
| 191 | if ( !ptr ) return allocate(nsize); |
| 192 | size = (size + alignMask) & ~alignMask; |
| 193 | nsize = (nsize + alignMask) & ~alignMask; |
| 194 | char * nptr = allocate(nsize); |
| 195 | DAS_VERIFYF(nptr,"out of memory?"); |
| 196 | memcpy ( nptr, ptr, das::min(size,nsize) ); |
| 197 | #if DAS_TRACK_ALLOCATIONS |
| 198 | if ( trackAllocations ) { |
| 199 | auto pAt = bigStuffAt.find(ptr); |
| 200 | if ( pAt != bigStuffAt.end() ) { |
| 201 | bigStuffAt[nptr] = pAt->second; |
| 202 | } |
| 203 | auto pCm = bigStuffComment.find(ptr); |
| 204 | if ( pCm != bigStuffComment.end() ) { |
| 205 | bigStuffComment[nptr] = pCm->second; |
| 206 | } |
| 207 | } |
| 208 | #endif |
| 209 | free(ptr, size); |
| 210 | return nptr; |
| 211 | } |
| 212 | |
| 213 | void MemoryModel::reset() { |
| 214 | for ( auto & itb : bigStuff ) { |
no test coverage detected