Github user jacksontj commented on a diff in the pull request: https://github.com/apache/trafficserver/pull/653#discussion_r66984823 --- Diff: iocore/hostdb/I_HostDBProcessor.h --- @@ -139,10 +141,62 @@ struct SRVInfo { unsigned int key; }; -struct HostDBInfo { +struct HostDBInfo : public RefCountObj { /** Internal IP address data. This is at least large enough to hold an IPv6 address. */ + + int iobuffer_index; + static HostDBInfo * + alloc(int size = 0) + { + size += sizeof(HostDBInfo); + int iobuffer_index = iobuffer_size_to_index(size); + 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; + return ret; + } + + void + free() + { + ioBufAllocator[iobuffer_index].free_void((void *)(this)); + } + + // return a version number-- so we can manage compatibility with the marshal/unmarshal + static VersionNumber + version() + { + return VersionNumber(1, 0); + } + + static HostDBInfo * + unmarshall(char *buf, unsigned int size) + { + if (size < sizeof(HostDBInfo)) { --- End diff -- No, this is the correct check. The `size` here is the total size of the entry. This include the HostDBInfo and potentially any additional space afterwards (strings, arrays, etc) which are all just offsets.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---