I agree that this is the preferred pattern given this situation, the message is very clear: this object is no longer in use and then when it's assigned again at the start it's clear it's in use again.
On Mon, Jul 6, 2015 at 9:51 PM, SolidWallOfCode <g...@git.apache.org> wrote: > Github user SolidWallOfCode commented on a diff in the pull request: > > https://github.com/apache/trafficserver/pull/240#discussion_r33935287 > > --- Diff: iocore/hostdb/HostDB.cc --- > @@ -2833,15 +2650,8 @@ ParseHostFile(char const *path) > } > } > > - if (!HostFilePairs.empty()) { > - // Need to sort by name so multiple address hosts are > - // contiguous. > - std::sort(HostFilePairs.begin(), HostFilePairs.end(), > &CmpHostFilePair); > - HostDBFileContinuation::scheduleUpdate(0); > - } else if (!HostFileKeys.empty()) { > - HostDBFileContinuation::scheduleRemove(-1, 0); > - } else { > - // Nothing in new data, nothing in old data, just clean up. > - HostDBFileContinuation::finish(0); > - } > + // Swap out hostDB's map for ours > + hostDB.hosts_file_ptr = parsed_hosts_file_ptr; > + // Make a new map, so we can do it all again > + parsed_hosts_file_ptr = new RefCountedHostsFileMap(); > --- End diff -- > > jacksont - I would have just assigned `NULL` to the pointer there and > delayed the call to `new` until it was needed (at the start of the next > load). > > > --- > 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. > --- >