From bd6336c629841c6db3a6ca53a936d629d34db53b Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:15:16 +0200 Subject: 4.1 --- shared/zstring.h | 216 ------------------------------------------------------- 1 file changed, 216 deletions(-) delete mode 100644 shared/zstring.h (limited to 'shared/zstring.h') diff --git a/shared/zstring.h b/shared/zstring.h deleted file mode 100644 index 8c30007b..00000000 --- a/shared/zstring.h +++ /dev/null @@ -1,216 +0,0 @@ -// ************************************************************************** -// * This file is part of the FreeFileSync project. It is distributed under * -// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * -// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** - -#ifndef ZSTRING_H_INCLUDED -#define ZSTRING_H_INCLUDED - -#include "zbase.h" -#include //strcmp() - -#ifndef NDEBUG -#include "boost_thread_wrap.h" //include -#include -#endif - - -#ifndef NDEBUG -class LeakChecker //small test for memory leaks -{ -public: - void insert(const void* ptr, size_t size) - { - boost::lock_guard dummy(lockActStrings); - if (activeStrings.find(ptr) != activeStrings.end()) - reportProblem(std::string("Fatal Error: New memory points into occupied space: ") + rawMemToString(ptr, size)); - - activeStrings[ptr] = size; - } - - void remove(const void* ptr) - { - boost::lock_guard dummy(lockActStrings); - if (activeStrings.find(ptr) == activeStrings.end()) - reportProblem(std::string("Fatal Error: No memory available for deallocation at this location!")); - - activeStrings.erase(ptr); - } - - static LeakChecker& instance(); - -private: - LeakChecker() {} - LeakChecker(const LeakChecker&); - LeakChecker& operator=(const LeakChecker&); - ~LeakChecker(); - - static std::string rawMemToString(const void* ptr, size_t size); - void reportProblem(const std::string& message); //throw (std::logic_error) - - boost::mutex lockActStrings; - typedef std::map VoidPtrSizeMap; - VoidPtrSizeMap activeStrings; -}; -#endif //NDEBUG - - -class AllocatorFreeStoreChecked -{ -public: - static void* allocate(size_t size) //throw (std::bad_alloc) - { -#ifndef NDEBUG - void* newMem = ::operator new(size); - LeakChecker::instance().insert(newMem, size); //test Zbase for memory leaks - return newMem; -#else - return ::operator new(size); -#endif - } - - static void deallocate(void* ptr) - { -#ifndef NDEBUG - LeakChecker::instance().remove(ptr); //check for memory leaks -#endif - ::operator delete(ptr); - } - - static size_t calcCapacity(size_t length) { return std::max(16, length + length / 2); } //exponential growth + min size -}; - - -//############################## helper functions ############################################# -#if defined(FFS_WIN) || defined(FFS_LINUX) -//Compare filenames: Windows does NOT distinguish between upper/lower-case, while Linux DOES -template class SP, class AP> int cmpFileName(const Zbase& lhs, const Zbase& rhs); - -struct LessFilename //case-insensitive on Windows, case-sensitive on Linux -{ - template class SP, class AP> - bool operator()(const Zbase& lhs, const Zbase& rhs) const; -}; - -struct EqualFilename //case-insensitive on Windows, case-sensitive on Linux -{ - template class SP, class AP> - bool operator()(const Zbase& lhs, const Zbase& rhs) const; -}; -#endif - -#ifdef FFS_WIN -template