You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2016/12/16 19:31:08 UTC

orc git commit: ORC-122. Use unique_ptr to wrap Timezone instances in the cache.

Repository: orc
Updated Branches:
  refs/heads/master 31267f100 -> f74cc0624


ORC-122. Use unique_ptr to wrap Timezone instances in the cache.

Fixes #73

Signed-off-by: Owen O'Malley <om...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/f74cc062
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/f74cc062
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/f74cc062

Branch: refs/heads/master
Commit: f74cc06244ad8b8367ebf551e74a04ecfc6b1c06
Parents: 31267f1
Author: Deepak Majeti <de...@hpe.com>
Authored: Fri Dec 16 12:27:12 2016 -0500
Committer: Owen O'Malley <om...@apache.org>
Committed: Fri Dec 16 11:30:11 2016 -0800

----------------------------------------------------------------------
 c++/src/Timezone.cc | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/f74cc062/c++/src/Timezone.cc
----------------------------------------------------------------------
diff --git a/c++/src/Timezone.cc b/c++/src/Timezone.cc
index 73026d2..4b82034 100644
--- a/c++/src/Timezone.cc
+++ b/c++/src/Timezone.cc
@@ -651,7 +651,7 @@ namespace orc {
     DIAGNOSTIC_IGNORE("-Wexit-time-destructors")
   #endif
   static std::mutex timezone_mutex;
-  static std::map<std::string, Timezone*> timezoneCache;
+  static std::map<std::string, std::unique_ptr<Timezone> > timezoneCache;
   DIAGNOSTIC_POP
 
   Timezone::~Timezone() {
@@ -691,10 +691,10 @@ namespace orc {
   const Timezone& getTimezoneByFilename(const std::string& filename) {
     // ORC-110
     std::lock_guard<std::mutex> timezone_lock(timezone_mutex);
-    std::map<std::string, Timezone*>::iterator itr =
+    std::map<std::string, std::unique_ptr<Timezone> >::iterator itr =
       timezoneCache.find(filename);
     if (itr != timezoneCache.end()) {
-      return *(itr->second);
+      return *(itr->second).get();
     }
     int in = open(filename.c_str(), O_RDONLY);
     if (in == -1) {
@@ -729,9 +729,8 @@ namespace orc {
       err << "failed to close " << filename << " - " << strerror(errno);
       throw TimezoneError(err.str());
     }
-    Timezone* result = new TimezoneImpl(filename, buffer);
-    timezoneCache[filename] = result;
-    return *result;
+    timezoneCache[filename].reset(new TimezoneImpl(filename, buffer));
+    return *timezoneCache[filename].get();
   }
 
   /**