From: Francesco Chemolli Date: Sat, 2 Feb 2013 11:36:38 +0000 (+0100) Subject: Removed useless MimeIcon::_free and some useless whitespace X-Git-Tag: SQUID_3_4_0_1~279^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=100f7d8b1a4eb0982445fa7ddd0009a24e003460;p=thirdparty%2Fsquid.git Removed useless MimeIcon::_free and some useless whitespace --- diff --git a/src/mime.cc b/src/mime.cc index dbc98b7d77..9ec45f3ce7 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -42,7 +42,6 @@ #include "Mem.h" #include "MemBuf.h" #include "mime.h" -#include "MemObject.h" #include "RequestFlags.h" #include "SquidConfig.h" #include "Store.h" @@ -66,12 +65,11 @@ public: ~MimeIcon (); void setName (char const *); char const * getName () const; - void _free(); void load(); void created (StoreEntry *newEntry); private: - char *icon; + const char *icon; char *url; }; @@ -181,7 +179,8 @@ MimeIcon::MimeIcon () : icon (NULL), url (NULL) MimeIcon::~MimeIcon () { - _free(); + safe_free (icon); + safe_free (url); } void @@ -199,13 +198,6 @@ MimeIcon::getName () const return icon; } -void -MimeIcon::_free() -{ - safe_free (icon); - safe_free (url); -} - char const * mimeGetIcon(const char *fn) { @@ -430,34 +422,28 @@ MimeIcon::load() void MimeIcon::created (StoreEntry *newEntry) { - /* is already in the store, do nothing */ - + /* if the icon is already in the store, do nothing */ if (!newEntry->isNull()) return; int fd; - int n; - RequestFlags flags; - struct stat sb; - LOCAL_ARRAY(char, path, MAXPATHLEN); - char *buf; snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon); fd = file_open(path, O_RDONLY | O_BINARY); - if (fd < 0) { - debugs(25, DBG_CRITICAL, "mimeLoadIconFile: " << path << ": " << xstrerror()); + debugs(25, DBG_CRITICAL, "mimeLoadIconFile: " << path << ": " + << xstrerror()); return; } - if (fstat(fd, &sb) < 0) { - debugs(25, DBG_CRITICAL, "mimeLoadIconFile: FD " << fd << ": fstat: " << xstrerror()); + debugs(25, DBG_CRITICAL, "mimeLoadIconFile: FD " << fd << ": fstat: " + << xstrerror()); file_close(fd); return; } @@ -477,33 +463,23 @@ MimeIcon::created (StoreEntry *newEntry) HttpReply *reply = new HttpReply; - reply->setHeaders(HTTP_OK, NULL, mimeGetContentType(icon), sb.st_size, sb.st_mtime, -1); - + reply->setHeaders(HTTP_OK, NULL, mimeGetContentType(icon), sb.st_size, + sb.st_mtime, -1); reply->cache_control = new HttpHdrCc(); - reply->cache_control->maxAge(86400); - reply->header.putCc(reply->cache_control); - e->replaceHttpReply(reply); /* read the file into the buffer and append it to store */ buf = (char *)memAllocate(MEM_4K_BUF); - while ((n = FD_READ_METHOD(fd, buf, 4096)) > 0) e->append(buf, n); file_close(fd); - e->flush(); - e->complete(); - e->timestampsSet(); - - debugs(25, 3, "Loaded icon " << url); - e->unlock(); - memFree(buf, MEM_4K_BUF); + debugs(25, 3, "Loaded icon " << url); }