/
libxdiffplugin.cpp
100 lines (66 loc) · 3.21 KB
/
libxdiffplugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*******************************************************************************
Copyright (C) The University of Auckland
OpenCOR is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenCOR is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://gnu.org/licenses>.
*******************************************************************************/
//==============================================================================
// LibXDiff plugin
//==============================================================================
#include "libxdiffplugin.h"
//==============================================================================
#include "xdiff.h"
//==============================================================================
namespace OpenCOR {
namespace LibXDiff {
//==============================================================================
PLUGININFO_FUNC LibXDiffPluginInfo()
{
Descriptions descriptions;
descriptions.insert("en", QString::fromUtf8(R"(a plugin to access <a href="http://xmailserver.org/xdiff-lib.html">LibXDiff</a>.)"));
descriptions.insert("fr", QString::fromUtf8(R"(une extension pour accéder <a href="http://xmailserver.org/xdiff-lib.html">LibXDiff</a>.)"));
return new PluginInfo(PluginInfo::Category::ThirdParty, false, false,
QStringList(),
descriptions);
}
//==============================================================================
static void * mallocWrapper(void *pData, unsigned int pSize)
{
Q_UNUSED(pData)
// Allocate some memory
return malloc(pSize); // NOLINT(cppcoreguidelines-no-malloc, hicpp-no-malloc)
}
//==============================================================================
static void freeWrapper(void *pData, void *pPointer)
{
Q_UNUSED(pData)
// Free the given memory
free(pPointer); // NOLINT(cppcoreguidelines-no-malloc, hicpp-no-malloc)
}
//==============================================================================
static void * reallocWrapper(void *pData, void *pPointer, unsigned int pSize)
{
Q_UNUSED(pData)
// Reallocate some memory
return realloc(pPointer, pSize); // NOLINT(cppcoreguidelines-no-malloc, hicpp-no-malloc)
}
//==============================================================================
LibXDiffPlugin::LibXDiffPlugin()
{
// Set our memory allocator
memallocator_t memoryAllocator = { nullptr, mallocWrapper, freeWrapper, reallocWrapper };
xdl_set_allocator(&memoryAllocator);
}
//==============================================================================
} // namespace LibXDiff
} // namespace OpenCOR
//==============================================================================
// End of file
//==============================================================================