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
0e8bbe5e
Commit
0e8bbe5e
authored
Apr 17, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Standardize behavior of CrtAllocator::Malloc()
parent
4cd14b7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
allocators.h
include/rapidjson/allocators.h
+6
-1
allocatorstest.cpp
test/unittest/allocatorstest.cpp
+2
-0
No files found.
include/rapidjson/allocators.h
View file @
0e8bbe5e
...
...
@@ -62,7 +62,12 @@ concept Allocator {
class
CrtAllocator
{
public
:
static
const
bool
kNeedFree
=
true
;
void
*
Malloc
(
size_t
size
)
{
return
std
::
malloc
(
size
);
}
void
*
Malloc
(
size_t
size
)
{
if
(
size
)
// behavior of malloc(0) is implementation defined.
return
std
::
malloc
(
size
);
else
return
NULL
;
// standardize to returning NULL.
}
void
*
Realloc
(
void
*
originalPtr
,
size_t
originalSize
,
size_t
newSize
)
{
(
void
)
originalSize
;
return
std
::
realloc
(
originalPtr
,
newSize
);
}
static
void
Free
(
void
*
ptr
)
{
std
::
free
(
ptr
);
}
};
...
...
test/unittest/allocatorstest.cpp
View file @
0e8bbe5e
...
...
@@ -26,6 +26,8 @@ using namespace rapidjson;
template
<
typename
Allocator
>
void
TestAllocator
(
Allocator
&
a
)
{
EXPECT_TRUE
(
a
.
Malloc
(
0
)
==
0
);
uint8_t
*
p
=
(
uint8_t
*
)
a
.
Malloc
(
100
);
EXPECT_TRUE
(
p
!=
0
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
...
...
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