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
81678272
Commit
81678272
authored
Jun 04, 2015
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #349 emscripten alignment issue
parent
ce0184e7
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
a.cpp
emscripten/a.cpp
+25
-0
allocators.h
include/rapidjson/allocators.h
+3
-3
rapidjson.h
include/rapidjson/rapidjson.h
+1
-1
No files found.
emscripten/a.cpp
0 → 100644
View file @
81678272
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
#define private public
#include "rapidjson/document.h"
int
main
()
{
// std::ifstream in_file("config.json", std::ios::in);
rapidjson
::
Document
json_config_
;
// std::string json_string(
// (std::istreambuf_iterator<char>(in_file)),
// std::istreambuf_iterator<char>());
std
::
string
json_string
(
"{
\"
float_test
\"
: 75.0}"
);
// if (!json_string.empty()) {
json_config_
.
Parse
(
json_string
.
c_str
());
// }
printf
(
"%p
\n
"
,
&
json_config_
);
printf
(
"%p
\n
"
,
&
json_config_
.
data_
.
o
.
members
[
0
].
value
.
data_
.
n
.
d
);
std
::
cout
<<
json_config_
[
"float_test"
].
GetDouble
()
<<
std
::
endl
;
}
\ No newline at end of file
include/rapidjson/allocators.h
View file @
81678272
...
...
@@ -181,7 +181,7 @@ public:
if
(
chunkHead_
==
0
||
chunkHead_
->
size
+
size
>
chunkHead_
->
capacity
)
AddChunk
(
chunk_capacity_
>
size
?
chunk_capacity_
:
size
);
void
*
buffer
=
reinterpret_cast
<
char
*>
(
chunkHead_
+
1
)
+
chunkHead_
->
size
;
void
*
buffer
=
reinterpret_cast
<
char
*>
(
chunkHead_
)
+
RAPIDJSON_ALIGN
(
sizeof
(
ChunkHeader
)
)
+
chunkHead_
->
size
;
chunkHead_
->
size
+=
size
;
return
buffer
;
}
...
...
@@ -199,7 +199,7 @@ public:
return
originalPtr
;
// Simply expand it if it is the last allocation and there is sufficient space
if
(
originalPtr
==
(
char
*
)(
chunkHead_
+
1
)
+
chunkHead_
->
size
-
originalSize
)
{
if
(
originalPtr
==
(
char
*
)(
chunkHead_
)
+
RAPIDJSON_ALIGN
(
sizeof
(
ChunkHeader
)
)
+
chunkHead_
->
size
-
originalSize
)
{
size_t
increment
=
static_cast
<
size_t
>
(
newSize
-
originalSize
);
increment
=
RAPIDJSON_ALIGN
(
increment
);
if
(
chunkHead_
->
size
+
increment
<=
chunkHead_
->
capacity
)
{
...
...
@@ -231,7 +231,7 @@ private:
void
AddChunk
(
size_t
capacity
)
{
if
(
!
baseAllocator_
)
ownBaseAllocator_
=
baseAllocator_
=
RAPIDJSON_NEW
(
BaseAllocator
());
ChunkHeader
*
chunk
=
reinterpret_cast
<
ChunkHeader
*>
(
baseAllocator_
->
Malloc
(
sizeof
(
ChunkHeader
)
+
capacity
));
ChunkHeader
*
chunk
=
reinterpret_cast
<
ChunkHeader
*>
(
baseAllocator_
->
Malloc
(
RAPIDJSON_ALIGN
(
sizeof
(
ChunkHeader
)
)
+
capacity
));
chunk
->
capacity
=
capacity
;
chunk
->
size
=
0
;
chunk
->
next
=
chunkHead_
;
...
...
include/rapidjson/rapidjson.h
View file @
81678272
...
...
@@ -223,7 +223,7 @@
//! Whether using 64-bit architecture
#ifndef RAPIDJSON_64BIT
#if defined(__LP64__) || defined(_WIN64)
#if defined(__LP64__) || defined(_WIN64)
|| defined(__EMSCRIPTEN__)
#define RAPIDJSON_64BIT 1
#else
#define RAPIDJSON_64BIT 0
...
...
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