void gep::StdAllocator::destroyInstance() { ScopedLock<Mutex> lock(s_creationMutex); if(s_globalInstance != nullptr) { #ifdef TRACK_MEMORY_LEAKS auto temp = (LeakDetectorAllocatorStatistics*)s_globalInstance; auto wrapped = (StdAllocator*)temp->getWrapped(); { // Will empty the file if it already existed. std::ofstream leakfile("memoryLeaks.log", std::ios_base::trunc); if(temp->hasLeaks()) { temp->findLeaks(leakfile); GEP_ASSERT(false, "you have memory leaks, check 'memoryLeaks.log' for details"); } else { leakfile << "No leaks detected." << std::endl; } } temp->~LeakDetectorAllocatorStatistics(); wrapped->~StdAllocator(); #else auto temp = s_globalInstance; s_globalInstance = nullptr; temp->~StdAllocator(); #endif } }
void TIFF::registerImageJTags() { // This is optional, used for quieting libtiff messages about // unknown tags by registering them. This doesn't work // completely since some warnings will be issued reading the // first directory, before we can register them. This is // deprecated in libtiff4, so guard against future removal. // // These static strings are to provide a writable string to // comply with the TIFFFieldInfo interface which can't be // assigned const string literals. They must outlive the // registered field info. static std::string ijbc("ImageJMetadataByteCounts"); static std::string ij("ImageJMetadata"); static const TIFFFieldInfo ImageJFieldInfo[] = { { TIFFTAG_IMAGEJ_META_DATA_BYTE_COUNTS, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG, FIELD_CUSTOM, true, true, const_cast<char *>(ijbc.c_str()) }, { TIFFTAG_IMAGEJ_META_DATA, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_BYTE, FIELD_CUSTOM, true, true, const_cast<char *>(ij.c_str()) } }; ::TIFF *tiffraw = reinterpret_cast< ::TIFF *>(getWrapped()); Sentry sentry; int e = TIFFMergeFieldInfo(tiffraw, ImageJFieldInfo, boost::size(ImageJFieldInfo)); if (e) sentry.error(); }