Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/xml memleak fix #190

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
401 changes: 315 additions & 86 deletions Platform/Windows/ReadiumSDK/ReadiumSDK.vcxproj

Large diffs are not rendered by default.

26 changes: 24 additions & 2 deletions Platform/Windows/ReadiumSDK/ePub3/ePub3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
Expand All @@ -39,7 +39,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -261,16 +261,29 @@ cscript MakeHeaders.js</Command>
<ClCompile Include="..\..\..\..\ePub3\ePub\cfi.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\container.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\content_handler.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\content_module_manager.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\credential_request.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\encryption.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\epub_collection.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain_byte_stream.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain_byte_stream_range.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_manager.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_manager_impl.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\font_obfuscation.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\glossary.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\initialization.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\library.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\link.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\manifest.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\media-overlays_smil_data.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\media-overlays_smil_model.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\media_support_info.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\nav_point.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\nav_table.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\object_preprocessor.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\package.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\PassThroughFilter.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\property.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\property_extension.cpp" />
<ClCompile Include="..\..\..\..\ePub3\ePub\property_holder.cpp" />
Expand Down Expand Up @@ -323,6 +336,8 @@ cscript MakeHeaders.js</Command>
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_fopen_index.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_fread.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_free.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_fseek.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_ftell.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_get_archive_comment.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_get_archive_flag.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_get_file_comment.c" />
Expand Down Expand Up @@ -352,9 +367,16 @@ cscript MakeHeaders.js</Command>
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_unchange_all.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_unchange_archive.c" />
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_unchange_data.c" />
<ClCompile Include="..\..\..\..\ePub3\utilities\byte_buffer.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\byte_stream.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\CPUCacheUtils_win.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\epub_locale.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\error_handler.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\executor.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\future.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\iri.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\optional.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\path_help.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\ref_counted.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\ring_buffer.cpp" />
<ClCompile Include="..\..\..\..\ePub3\utilities\run_loop_windows.cpp" />
Expand Down
66 changes: 66 additions & 0 deletions Platform/Windows/ReadiumSDK/ePub3/ePub3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -638,5 +638,71 @@
<ClCompile Include="..\..\..\..\ePub3\ePub\property_holder.cpp">
<Filter>Source Files\ePub\Components\Properties</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\byte_buffer.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\CPUCacheUtils_win.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\error_handler.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\executor.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\future.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\optional.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\utilities\path_help.cpp">
<Filter>Source Files\utilities</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\content_module_manager.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\credential_request.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\epub_collection.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain_byte_stream.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_chain_byte_stream_range.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_manager.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\filter_manager_impl.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\initialization.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\link.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\media-overlays_smil_data.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\media-overlays_smil_model.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ePub\PassThroughFilter.cpp">
<Filter>Source Files\ePub</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_ftell.c">
<Filter>Source Files\ThirdParty\libzip</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\ePub3\ThirdParty\libzip\zip_fseek.c">
<Filter>Source Files\ThirdParty\libzip</Filter>
</ClCompile>
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions ePub3/ThirdParty/google-url/base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ enum { DEBUG_MODE = 0 };
// above.
class LogMessage {
public:
LogMessage(const char* file, int line, LogSeverity severity, int ctr) {}
LogMessage(const char* file, int line, LogSeverity severity, int ctr);// {}

// Two special constructors that generate reduced amounts of code at
// LOG call sites for common cases.
Expand All @@ -427,22 +427,22 @@ class LogMessage {
//
// Using this constructor instead of the more complex constructor above
// saves a couple of bytes per call site.
LogMessage(const char* file, int line) {}
LogMessage(const char* file, int line);// {}

// Used for LOG(severity) where severity != INFO. Implied
// are: ctr = 0
//
// Using this constructor instead of the more complex constructor above
// saves a couple of bytes per call site.
LogMessage(const char* file, int line, LogSeverity severity) {}
LogMessage(const char* file, int line, LogSeverity severity);// {}

// A special constructor used for check failures.
// Implied severity = LOG_FATAL
LogMessage(const char* file, int line, const CheckOpString& result) {}
LogMessage(const char* file, int line, const CheckOpString& result);// {}

~LogMessage() {}
~LogMessage();// {}

std::ostream& stream() { return stream_; }
std::ostream& stream() { return stream_; }

private:
void Init(const char* file, int line);
Expand Down
2 changes: 1 addition & 1 deletion ePub3/ePub/PassThroughFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <ePub3/encryption.h>
#include REGEX_INCLUDE
#include <cstring>
#import <ePub3/utilities/byte_stream.h>
#include <ePub3/utilities/byte_stream.h> //#import <ePub3/utilities/byte_stream.h>

EPUB3_BEGIN_NAMESPACE

Expand Down
1 change: 1 addition & 0 deletions ePub3/ePub/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Container : public PointerType<Container>

///
/// Creates and returns a new Container instance by calling OpenContainerAsync() and blocking.
EPUB3_EXPORT
static ContainerPtr
OpenContainer(const string& path);

Expand Down
2 changes: 1 addition & 1 deletion ePub3/ePub/filter_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ std::shared_ptr<ByteStream> FilterChain::GetFilterChainByteStreamRange(ConstMani
std::unique_ptr<ByteStream> FilterChain::GetFilterChainByteStreamRange(ConstManifestItemPtr item, SeekableByteStream *rawInput) const
{
unique_ptr<ByteStream> resultStream;
uint nFilters = 0;
int nFilters = 0;
for (ContentFilterPtr filter : _filters)
{
if (filter->TypeSniffer()(item))
Expand Down
1 change: 1 addition & 0 deletions ePub3/ePub/font_obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#elif EPUB_PLATFORM(WIN)
#include <windows.h>
#include <Wincrypt.h>
#include "error_handler.h"
#elif EPUB_PLATFORM(WINRT)
using namespace ::Platform;
using namespace ::Windows::Security::Cryptography;
Expand Down
32 changes: 31 additions & 1 deletion ePub3/ePub/initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,35 @@ void PopulateFilterManager()
});
}

EPUB3_END_NAMESPACE
SDKInitializeAndRelease g_instance;

SDKInitializeAndRelease::SDKInitializeAndRelease()
{
if (this != &g_instance)
throw std::exception("SDKInitializeAndRelease should be a global static");

Initialize();
}
SDKInitializeAndRelease::~SDKInitializeAndRelease()
{
Teardown();
}
void SDKInitializeAndRelease::Initialize()
{
#if EPUB_USE(LIBXML2)
xmlInitParser(); // Please check this invocation before any libxml2 parsing
#endif
}
void SDKInitializeAndRelease::Teardown()
{
#if EPUB_USE(LIBXML2)
// One should call xmlCleanupParser() only when the process has finished using the library and all XML/HTML documents built with it.
xmlCleanupParser();
#endif
}
SDKInitializeAndRelease& SDKInitializeAndRelease::Instance()
{
return g_instance; // returns the global static instance (for memory debugging purposes as the example)
}

EPUB3_END_NAMESPACE
18 changes: 16 additions & 2 deletions ePub3/ePub/initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@

EPUB3_BEGIN_NAMESPACE

void InitializeSdk();
EPUB3_EXPORT void InitializeSdk();

EPUB3_EXPORT void PopulateFilterManager();

// The static signleton object, to initialize and teardown the SDK
// TODO: Add your global initialization and release code into Initialize() and Teardown() methods respectively
class SDKInitializeAndRelease
{
private:
public:
SDKInitializeAndRelease();
~SDKInitializeAndRelease();
EPUB3_EXPORT void Initialize(); // helper function, can be called to initialize the SDK memory (i.e. in case of memory leak debugging)
EPUB3_EXPORT void Teardown(); // helper function, can be called to release the SDK memory (i.e. in case of memory leak debugging)
EPUB3_EXPORT static SDKInitializeAndRelease& Instance();
};

void PopulateFilterManager();

EPUB3_END_NAMESPACE

Expand Down
12 changes: 6 additions & 6 deletions ePub3/ePub/media-overlays_smil_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ Parser that reads SMIL XML files into an in-memory data model

const void PercentToPosition(double percent, SMILDataPtr & smilData, uint32_t & smilIndex, shared_ptr<const SMILData::Parallel>& par, uint32_t & parIndex, uint32_t & milliseconds) const;

//EPUB3_EXPORT
EPUB3_EXPORT

static std::vector<string>::size_type GetSkippablesCount()
{
return _Skippables.size();
}

//EPUB3_EXPORT
EPUB3_EXPORT

static string GetSkippable(std::vector<string>::size_type i)
{
Expand All @@ -154,14 +154,14 @@ Parser that reads SMIL XML files into an in-memory data model
return str;
}

//EPUB3_EXPORT
EPUB3_EXPORT

static std::vector<string>::size_type GetEscapablesCount()
{
return _Escapables.size();
}

//EPUB3_EXPORT
EPUB3_EXPORT

static string GetEscapable(std::vector<string>::size_type i)
{
Expand All @@ -174,10 +174,10 @@ Parser that reads SMIL XML files into an in-memory data model
return str;
}

private:
public:
static const std::vector<string> _Skippables;
static const std::vector<string> _Escapables;

private:
bool _excludeAudioDuration;

void resetData();
Expand Down
1 change: 1 addition & 0 deletions ePub3/ePub/nav_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class NavigationPoint : public NavigationElement, public PointerType<NavigationP

///
/// Turns the Content() href into an absolute value, similar to ManifestItem::AbsolutePath().
EPUB3_EXPORT
string AbsolutePath(ConstPackagePtr pkg) const;

protected:
Expand Down
1 change: 1 addition & 0 deletions ePub3/ePub/spine.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class SpineItem : public PointerType<SpineItem>, public OwnedBy<Package>, public
const string& Idref() const { return _idref; }
///
/// Obtains the manifest item corresponding to this spine item.
EPUB3_EXPORT
shared_ptr<ManifestItem> ManifestItem() const;
///
/// Returns `true` if this item is linear, `false` otherwise.
Expand Down
2 changes: 2 additions & 0 deletions ePub3/utilities/integer_sequence.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if 1
//
// integer_sequence.h
// ePub3
Expand Down Expand Up @@ -80,3 +81,4 @@ using make_index_sequence = make_integer_sequence<std::size_t, _Ep, _Sp>;
EPUB3_END_NAMESPACE

#endif
#endif
8 changes: 4 additions & 4 deletions ePub3/utilities/iri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void IRI::AddStandardScheme(const string& scheme)
url_util::AddStandardScheme(scheme.c_str());
}

IRI::IRI(const string& iriStr) : _urnComponents(), _url(make_unique<GURL>(iriStr.stl_str())), _pureIRI(iriStr)
IRI::IRI(const string& iriStr) : _urnComponents(), _url(ePub3::make_unique<GURL>(iriStr.stl_str())), _pureIRI(iriStr)
{
// is it a URN?
if ( iriStr.find("urn:", 0, 4) == 0 )
Expand All @@ -64,7 +64,7 @@ IRI::IRI(const string& nameID, const string& namespacedString) :
_urnComponents({gURNScheme, nameID, namespacedString}),
#endif
_pureIRI(_Str("urn:", nameID, ":", namespacedString)),
_url(make_unique<GURL>(_pureIRI.stl_str()))
_url(ePub3::make_unique<GURL>(_pureIRI.stl_str()))
{
#if !EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS)
_urnComponents.push_back(gURNScheme);
Expand All @@ -87,7 +87,7 @@ IRI::IRI(const string& scheme, const string& host, const string& path, const str
if ( !fragment.empty() )
_pureIRI += _Str("#", fragment);

_url = make_unique<GURL>(_pureIRI.stl_str());
_url = ePub3::make_unique<GURL>(_pureIRI.stl_str());
}
IRI::~IRI()
{
Expand Down Expand Up @@ -127,7 +127,7 @@ IRI& IRI::operator=(const string& str)
}
}

auto newURL = make_unique<GURL>(str.stl_str());
auto newURL = ePub3::make_unique<GURL>(str.stl_str());
if ( !newURL->is_valid() && !isURN )
throw std::invalid_argument(_Str("IRI: '", str, "' is not a valid URL string."));

Expand Down
2 changes: 1 addition & 1 deletion ePub3/utilities/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void fail(const char* expr, const char* file, unsigned line)
# elif defined(__GNUC__) || EPUB_PLATFORM(ANDROID)
__assert(file, line, expr);
# else
# warning I dont know how to fire assertion internals on this compiler.
//# warning I dont know how to fire assertion internals on this compiler.
# endif
}
#endif
Expand Down
Loading