return (true);
}
-void
+MemorySegmentMapped*
ZoneTableSegmentMapped::openReadWrite(const std::string& filename,
bool create)
{
}
}
- mem_sgmt_.reset(segment.release());
+ return (segment.release());
}
-void
+MemorySegmentMapped*
ZoneTableSegmentMapped::openReadOnly(const std::string& filename) {
// In case the checksum or table header is missing, we throw. We
// want the segment to be automatically destroyed then.
}
}
- mem_sgmt_.reset(segment.release());
+ return (segment.release());
}
void
sync();
}
+ // In case current_filename_ below fails, we want the segment to be
+ // automatically destroyed.
+ std::auto_ptr<MemorySegmentMapped> segment;
+
switch (mode) {
case CREATE:
- openReadWrite(filename, true);
+ segment.reset(openReadWrite(filename, true));
break;
case READ_WRITE:
- openReadWrite(filename, false);
+ segment.reset(openReadWrite(filename, false));
break;
case READ_ONLY:
- openReadOnly(filename);
+ segment.reset(openReadOnly(filename));
}
- current_mode_ = mode;
current_filename_ = filename;
+ current_mode_ = mode;
+ mem_sgmt_.reset(segment.release());
}
void
bool processHeader(isc::util::MemorySegmentMapped& segment, bool create,
std::string& error_msg);
- void openReadWrite(const std::string& filename, bool create);
- void openReadOnly(const std::string& filename);
+ isc::util::MemorySegmentMapped* openReadWrite(const std::string& filename,
+ bool create);
+ isc::util::MemorySegmentMapped* openReadOnly(const std::string& filename);
template<typename T> T* getHeaderHelper() const;