@@ -651,7 +651,7 @@ namespace orc {
651651 DIAGNOSTIC_IGNORE(" -Wexit-time-destructors" )
652652 #endif
653653 static std::mutex timezone_mutex;
654- static std::map<std::string, Timezone* > timezoneCache;
654+ static std::map<std::string, std::unique_ptr< Timezone> > timezoneCache;
655655 DIAGNOSTIC_POP
656656
657657 Timezone::~Timezone () {
@@ -691,10 +691,10 @@ namespace orc {
691691 const Timezone& getTimezoneByFilename (const std::string& filename) {
692692 // ORC-110
693693 std::lock_guard<std::mutex> timezone_lock (timezone_mutex);
694- std::map<std::string, Timezone* >::iterator itr =
694+ std::map<std::string, std::unique_ptr< Timezone> >::iterator itr =
695695 timezoneCache.find (filename);
696696 if (itr != timezoneCache.end ()) {
697- return *(itr->second );
697+ return *(itr->second ). get () ;
698698 }
699699 int in = open (filename.c_str (), O_RDONLY);
700700 if (in == -1 ) {
@@ -729,9 +729,8 @@ namespace orc {
729729 err << " failed to close " << filename << " - " << strerror (errno);
730730 throw TimezoneError (err.str ());
731731 }
732- Timezone* result = new TimezoneImpl (filename, buffer);
733- timezoneCache[filename] = result;
734- return *result;
732+ timezoneCache[filename].reset (new TimezoneImpl (filename, buffer));
733+ return *timezoneCache[filename].get ();
735734 }
736735
737736 /* *
0 commit comments