| 408 | } |
| 409 | |
| 410 | void FunctionContext::Free(uint8_t* buffer) noexcept { |
| 411 | assert(!impl_->closed_); |
| 412 | if (buffer == NULL) return; |
| 413 | VLOG_ROW << "Free: FunctionContext=" << this << " " |
| 414 | << reinterpret_cast<void*>(buffer); |
| 415 | if (impl_->debug_) { |
| 416 | map<uint8_t*, int>::iterator it = impl_->allocations_.find(buffer); |
| 417 | if (it != impl_->allocations_.end()) { |
| 418 | // fill in garbage value into the buffer to increase the chance of detecting misuse |
| 419 | memset(buffer, 0xff, it->second); |
| 420 | impl_->allocations_.erase(it); |
| 421 | impl_->udf_pool_->Free(buffer); |
| 422 | } else { |
| 423 | SetError("FunctionContext::Free() called on buffer that is already freed or was " |
| 424 | "not allocated."); |
| 425 | } |
| 426 | } else { |
| 427 | impl_->udf_pool_->Free(buffer); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | void FunctionContext::TrackAllocation(int64_t bytes) { |
| 432 | assert(!impl_->closed_); |