Permalink
Browse files

Don't use String/AttachDeprecated just to free a malloc'd buffer.

Remove one use of AttachDeprecated; all its being used for is
to optionally free a buffer; that's not so hard to do.
  • Loading branch information...
1 parent 92cf3eb commit d7e894bea954f876cf77f5745a7b8765132728f4 @edwinsmith edwinsmith committed with joelpob Sep 26, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/runtime/base/server/http_request_handler.cpp
@@ -173,7 +173,7 @@ void HttpRequestHandler::handleRequest(Transport *transport) {
bool original = compressed;
// check against static content cache
if (StaticContentCache::TheCache.find(path, data, len, compressed)) {
- String str;
+ bool free_data = false;
// (qigao) not calling stat at this point because the timestamp of
// local cache file is not valuable, maybe misleading. This way
// the Last-Modified header will not show in response.
@@ -184,12 +184,13 @@ void HttpRequestHandler::handleRequest(Transport *transport) {
throw FatalErrorException("cannot unzip compressed data");
}
compressed = false;
- str = NEW(StringData)(data, len, AttachDeprecated);
+ free_data = true;
}
sendStaticContent(transport, data, len, 0, compressed, path, ext);
StaticContentCache::TheFileCache->adviseOutMemory();
ServerStats::LogPage(path, 200);
GetAccessLog().log(transport, vhost);
+ if (free_data) free(const_cast<char*>(data));
return;
}
}

0 comments on commit d7e894b

Please sign in to comment.