aboutsummaryrefslogtreecommitdiff
path: root/src/malloc.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-12-26 11:20:31 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-12-30 17:37:56 +0100
commite1edf114105b0f528ef662f79297603617297a6b (patch)
tree66bc44fef2dea2dcb8e474e999787c9158ec1b25 /src/malloc.cpp
parent5c41d3a1078895ed096b416db15c91108bccad87 (diff)
downloadPROJ-e1edf114105b0f528ef662f79297603617297a6b.tar.gz
PROJ-e1edf114105b0f528ef662f79297603617297a6b.zip
Allocate PJ* as a C++ object
Diffstat (limited to 'src/malloc.cpp')
-rw-r--r--src/malloc.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/malloc.cpp b/src/malloc.cpp
index c8681570..0e80912e 100644
--- a/src/malloc.cpp
+++ b/src/malloc.cpp
@@ -44,6 +44,8 @@
#include <stdlib.h>
#include <string.h>
+#include <new>
+
#include "proj.h"
#include "projects.h"
@@ -188,7 +190,16 @@ void pj_free(PJ *P) {
P->destructor (P, proj_errno(P));
}
+/*****************************************************************************/
+// cppcheck-suppress uninitMemberVar
+PJconsts::PJconsts(): destructor(pj_default_destructor) {}
+/*****************************************************************************/
+/*****************************************************************************/
+PJ *pj_new() {
+/*****************************************************************************/
+ return new(std::nothrow) PJ();
+}
/*****************************************************************************/
@@ -235,6 +246,6 @@ PJ *pj_default_destructor (PJ *P, int errlev) { /* Destructor */
pj_free (P->vgridshift);
pj_dealloc (static_cast<struct pj_opaque*>(P->opaque));
- pj_dealloc(P);
+ delete P;
return nullptr;
}