Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
4fa43bd4
Commit
4fa43bd4
authored
Oct 30, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #183 from pah/feature/wrapped-new-delete
Add customization macros for global new/delete
parents
dea1cdca
c557b230
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
6 deletions
+18
-6
allocators.h
include/rapidjson/allocators.h
+2
-2
document.h
include/rapidjson/document.h
+2
-2
stack.h
include/rapidjson/internal/stack.h
+2
-2
rapidjson.h
include/rapidjson/rapidjson.h
+12
-0
No files found.
include/rapidjson/allocators.h
View file @
4fa43bd4
...
...
@@ -105,7 +105,7 @@ public:
chunkHead_
(
0
),
chunk_capacity_
(
chunkSize
),
userBuffer_
(
0
),
baseAllocator_
(
baseAllocator
),
ownBaseAllocator_
(
0
)
{
if
(
!
baseAllocator_
)
ownBaseAllocator_
=
baseAllocator_
=
new
BaseAllocator
(
);
ownBaseAllocator_
=
baseAllocator_
=
RAPIDJSON_NEW
(
BaseAllocator
()
);
AddChunk
(
chunk_capacity_
);
}
...
...
@@ -135,7 +135,7 @@ public:
*/
~
MemoryPoolAllocator
()
{
Clear
();
delete
ownBaseAllocator_
;
RAPIDJSON_DELETE
(
ownBaseAllocator_
)
;
}
//! Deallocates all memory chunks, excluding the user-supplied buffer.
...
...
include/rapidjson/document.h
View file @
4fa43bd4
...
...
@@ -1634,7 +1634,7 @@ public:
allocator_
(
allocator
),
ownAllocator_
(
0
),
stack_
(
stackAllocator
,
stackCapacity
),
parseResult_
()
{
if
(
!
allocator_
)
ownAllocator_
=
allocator_
=
new
Allocator
(
);
ownAllocator_
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
...
...
@@ -1875,7 +1875,7 @@ private:
}
void
Destroy
()
{
delete
ownAllocator_
;
RAPIDJSON_DELETE
(
ownAllocator_
)
;
}
static
const
size_t
kDefaultStackCapacity
=
1024
;
...
...
include/rapidjson/internal/stack.h
View file @
4fa43bd4
...
...
@@ -38,7 +38,7 @@ public:
Stack
(
Allocator
*
allocator
,
size_t
stackCapacity
)
:
allocator_
(
allocator
),
ownAllocator
(
0
),
stack_
(
0
),
stackTop_
(
0
),
stackEnd_
(
0
),
initialCapacity_
(
stackCapacity
)
{
RAPIDJSON_ASSERT
(
stackCapacity
>
0
);
if
(
!
allocator_
)
ownAllocator
=
allocator_
=
new
Allocator
(
);
ownAllocator
=
allocator_
=
RAPIDJSON_NEW
(
Allocator
()
);
}
#if RAPIDJSON_HAS_CXX11_RVALUE_REFS
...
...
@@ -162,7 +162,7 @@ private:
void
Destroy
()
{
Allocator
::
Free
(
stack_
);
delete
ownAllocator
;
// Only delete if it is owned by the stack
RAPIDJSON_DELETE
(
ownAllocator
)
;
// Only delete if it is owned by the stack
}
// Prohibit copy constructor & assignment operator.
...
...
include/rapidjson/rapidjson.h
View file @
4fa43bd4
...
...
@@ -400,6 +400,18 @@ template<int x> struct StaticAssertTest {};
//!@endcond
///////////////////////////////////////////////////////////////////////////////
// new/delete
#ifndef RAPIDJSON_NEW
///! customization point for global \c new
#define RAPIDJSON_NEW(x) new x
#endif
#ifndef RAPIDJSON_DELETE
///! customization point for global \c delete
#define RAPIDJSON_DELETE(x) delete x
#endif
///////////////////////////////////////////////////////////////////////////////
// Allocators and Encodings
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment