From: Alex Rousskov Date: Fri, 16 Jul 2021 15:51:43 +0000 (-0400) Subject: Simplified Gopher client code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d518243a26d03d1db34f45243548024144db6a12;p=thirdparty%2Fsquid.git Simplified Gopher client code Its fake deleteThis() and swanSong() methods were not really needed, swanSong() was doing the cleanup that the destructor should be doing (because the _real_ swanSong() is not guaranteed to be called), and swanSong() implementation was actually a little buggy (creating a dangling StoreEntry pointer). --- diff --git a/src/gopher.cc b/src/gopher.cc index f33ef5d6db..6f05039449 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -97,11 +97,8 @@ public: entry->lock("gopherState"); *replybuf = 0; } - ~GopherStateData() {if(buf) swanSong();} - /* AsyncJob API emulated */ - void deleteThis(const char *aReason); - void swanSong(); + ~GopherStateData(); public: StoreEntry *entry; @@ -148,30 +145,16 @@ static void gopherStateFree(const CommCloseCbParams ¶ms) { GopherStateData *gopherState = (GopherStateData *)params.data; - - if (gopherState == NULL) - return; - - gopherState->deleteThis("gopherStateFree"); + delete gopherState; } -void -GopherStateData::deleteThis(const char *) -{ - swanSong(); - delete this; -} - -void -GopherStateData::swanSong() +GopherStateData::~GopherStateData() { if (entry) entry->unlock("gopherState"); - if (buf) { + if (buf) memFree(buf, MEM_4K_BUF); - buf = nullptr; - } } /**