ywkaras commented on a change in pull request #6858:
URL: https://github.com/apache/trafficserver/pull/6858#discussion_r438142405
##########
File path: iocore/hostdb/I_HostDBProcessor.h
##########
@@ -146,16 +146,17 @@ struct HostDBInfo : public RefCountObj {
ink_release_assert(iobuffer_index >= 0);
void *ptr = ioBufAllocator[iobuffer_index].alloc_void();
memset(ptr, 0, size);
- HostDBInfo *ret = new (ptr) HostDBInfo();
- ret->iobuffer_index = iobuffer_index;
+ HostDBInfo *ret = new (ptr) HostDBInfo();
+ ret->_iobuffer_index = iobuffer_index;
return ret;
}
void
free() override
{
- Debug("hostdb", "freeing %d bytes at [%p]", (1 << (7 + iobuffer_index)),
this);
- ioBufAllocator[iobuffer_index].free_void((void *)(this));
+ ink_release_assert(from_alloc());
Review comment:
The current code requires that instances of HostDBInfo be copyable. Not
all instances of HostDBInfo are created by the alloc() function. It will be
easier to debug accidental calls to free() with this assert, because with the
assert, they will corrupt the freelist, and it's hard to find the cause of
memory corruption.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]