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
ca9b2d18
Commit
ca9b2d18
authored
Sep 16, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #148 from pah/fixes/solaris
Alternative compilation fix for Solaris
parents
2475e952
5117f9e5
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
21 deletions
+24
-21
allocators.h
include/rapidjson/allocators.h
+4
-4
document.h
include/rapidjson/document.h
+6
-8
filewritestream.h
include/rapidjson/filewritestream.h
+2
-2
dtoa.h
include/rapidjson/internal/dtoa.h
+3
-3
memorybuffer.h
include/rapidjson/memorybuffer.h
+1
-1
rapidjson.h
include/rapidjson/rapidjson.h
+7
-2
stringbuffer.h
include/rapidjson/stringbuffer.h
+1
-1
No files found.
include/rapidjson/allocators.h
View file @
ca9b2d18
...
@@ -68,9 +68,9 @@ concept Allocator {
...
@@ -68,9 +68,9 @@ concept Allocator {
class
CrtAllocator
{
class
CrtAllocator
{
public
:
public
:
static
const
bool
kNeedFree
=
true
;
static
const
bool
kNeedFree
=
true
;
void
*
Malloc
(
size_t
size
)
{
return
malloc
(
size
);
}
void
*
Malloc
(
size_t
size
)
{
return
std
::
malloc
(
size
);
}
void
*
Realloc
(
void
*
originalPtr
,
size_t
originalSize
,
size_t
newSize
)
{
(
void
)
originalSize
;
return
realloc
(
originalPtr
,
newSize
);
}
void
*
Realloc
(
void
*
originalPtr
,
size_t
originalSize
,
size_t
newSize
)
{
(
void
)
originalSize
;
return
std
::
realloc
(
originalPtr
,
newSize
);
}
static
void
Free
(
void
*
ptr
)
{
free
(
ptr
);
}
static
void
Free
(
void
*
ptr
)
{
std
::
free
(
ptr
);
}
};
};
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
@@ -200,7 +200,7 @@ public:
...
@@ -200,7 +200,7 @@ public:
// Realloc process: allocate and copy memory, do not free original buffer.
// Realloc process: allocate and copy memory, do not free original buffer.
void
*
newBuffer
=
Malloc
(
newSize
);
void
*
newBuffer
=
Malloc
(
newSize
);
RAPIDJSON_ASSERT
(
newBuffer
!=
0
);
// Do not handle out-of-memory explicitly.
RAPIDJSON_ASSERT
(
newBuffer
!=
0
);
// Do not handle out-of-memory explicitly.
return
memcpy
(
newBuffer
,
originalPtr
,
originalSize
);
return
std
::
memcpy
(
newBuffer
,
originalPtr
,
originalSize
);
}
}
//! Frees a memory block (concept Allocator)
//! Frees a memory block (concept Allocator)
...
...
include/rapidjson/document.h
View file @
ca9b2d18
...
@@ -413,7 +413,6 @@ template <typename T> struct IsGenericValue : IsGenericValueImpl<T>::Type {};
...
@@ -413,7 +413,6 @@ template <typename T> struct IsGenericValue : IsGenericValueImpl<T>::Type {};
\tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document)
\tparam Encoding Encoding of the value. (Even non-string values need to have the same encoding in a document)
\tparam Allocator Allocator type for allocating memory of object, array and string.
\tparam Allocator Allocator type for allocating memory of object, array and string.
*/
*/
#pragma pack (push, 4)
template
<
typename
Encoding
,
typename
Allocator
=
MemoryPoolAllocator
<>
>
template
<
typename
Encoding
,
typename
Allocator
=
MemoryPoolAllocator
<>
>
class
GenericValue
{
class
GenericValue
{
public
:
public
:
...
@@ -1098,7 +1097,7 @@ public:
...
@@ -1098,7 +1097,7 @@ public:
MemberIterator
pos
=
MemberBegin
()
+
(
first
-
MemberBegin
());
MemberIterator
pos
=
MemberBegin
()
+
(
first
-
MemberBegin
());
for
(
MemberIterator
itr
=
pos
;
itr
!=
last
;
++
itr
)
for
(
MemberIterator
itr
=
pos
;
itr
!=
last
;
++
itr
)
itr
->~
Member
();
itr
->~
Member
();
memmove
(
&*
pos
,
&*
last
,
(
MemberEnd
()
-
last
)
*
sizeof
(
Member
));
std
::
memmove
(
&*
pos
,
&*
last
,
(
MemberEnd
()
-
last
)
*
sizeof
(
Member
));
data_
.
o
.
size
-=
(
last
-
first
);
data_
.
o
.
size
-=
(
last
-
first
);
return
pos
;
return
pos
;
}
}
...
@@ -1278,7 +1277,7 @@ int z = a[0u].GetInt(); // This works too.
...
@@ -1278,7 +1277,7 @@ int z = a[0u].GetInt(); // This works too.
ValueIterator
pos
=
Begin
()
+
(
first
-
Begin
());
ValueIterator
pos
=
Begin
()
+
(
first
-
Begin
());
for
(
ValueIterator
itr
=
pos
;
itr
!=
last
;
++
itr
)
for
(
ValueIterator
itr
=
pos
;
itr
!=
last
;
++
itr
)
itr
->~
GenericValue
();
itr
->~
GenericValue
();
memmove
(
pos
,
last
,
(
End
()
-
last
)
*
sizeof
(
GenericValue
));
std
::
memmove
(
pos
,
last
,
(
End
()
-
last
)
*
sizeof
(
GenericValue
));
data_
.
a
.
size
-=
(
last
-
first
);
data_
.
a
.
size
-=
(
last
-
first
);
return
pos
;
return
pos
;
}
}
...
@@ -1528,7 +1527,7 @@ private:
...
@@ -1528,7 +1527,7 @@ private:
void
SetArrayRaw
(
GenericValue
*
values
,
SizeType
count
,
Allocator
&
allocator
)
{
void
SetArrayRaw
(
GenericValue
*
values
,
SizeType
count
,
Allocator
&
allocator
)
{
flags_
=
kArrayFlag
;
flags_
=
kArrayFlag
;
data_
.
a
.
elements
=
(
GenericValue
*
)
allocator
.
Malloc
(
count
*
sizeof
(
GenericValue
));
data_
.
a
.
elements
=
(
GenericValue
*
)
allocator
.
Malloc
(
count
*
sizeof
(
GenericValue
));
memcpy
(
data_
.
a
.
elements
,
values
,
count
*
sizeof
(
GenericValue
));
std
::
memcpy
(
data_
.
a
.
elements
,
values
,
count
*
sizeof
(
GenericValue
));
data_
.
a
.
size
=
data_
.
a
.
capacity
=
count
;
data_
.
a
.
size
=
data_
.
a
.
capacity
=
count
;
}
}
...
@@ -1536,7 +1535,7 @@ private:
...
@@ -1536,7 +1535,7 @@ private:
void
SetObjectRaw
(
Member
*
members
,
SizeType
count
,
Allocator
&
allocator
)
{
void
SetObjectRaw
(
Member
*
members
,
SizeType
count
,
Allocator
&
allocator
)
{
flags_
=
kObjectFlag
;
flags_
=
kObjectFlag
;
data_
.
o
.
members
=
(
Member
*
)
allocator
.
Malloc
(
count
*
sizeof
(
Member
));
data_
.
o
.
members
=
(
Member
*
)
allocator
.
Malloc
(
count
*
sizeof
(
Member
));
memcpy
(
data_
.
o
.
members
,
members
,
count
*
sizeof
(
Member
));
std
::
memcpy
(
data_
.
o
.
members
,
members
,
count
*
sizeof
(
Member
));
data_
.
o
.
size
=
data_
.
o
.
capacity
=
count
;
data_
.
o
.
size
=
data_
.
o
.
capacity
=
count
;
}
}
...
@@ -1560,7 +1559,7 @@ private:
...
@@ -1560,7 +1559,7 @@ private:
str
=
(
Ch
*
)
allocator
.
Malloc
((
s
.
length
+
1
)
*
sizeof
(
Ch
));
str
=
(
Ch
*
)
allocator
.
Malloc
((
s
.
length
+
1
)
*
sizeof
(
Ch
));
data_
.
s
.
str
=
str
;
data_
.
s
.
str
=
str
;
}
}
memcpy
(
str
,
s
,
s
.
length
*
sizeof
(
Ch
));
std
::
memcpy
(
str
,
s
,
s
.
length
*
sizeof
(
Ch
));
str
[
s
.
length
]
=
'\0'
;
str
[
s
.
length
]
=
'\0'
;
}
}
...
@@ -1584,13 +1583,12 @@ private:
...
@@ -1584,13 +1583,12 @@ private:
const
Ch
*
const
str2
=
rhs
.
GetString
();
const
Ch
*
const
str2
=
rhs
.
GetString
();
if
(
str1
==
str2
)
{
return
true
;
}
// fast path for constant string
if
(
str1
==
str2
)
{
return
true
;
}
// fast path for constant string
return
(
memcmp
(
str1
,
str2
,
sizeof
(
Ch
)
*
len1
)
==
0
);
return
(
std
::
memcmp
(
str1
,
str2
,
sizeof
(
Ch
)
*
len1
)
==
0
);
}
}
Data
data_
;
Data
data_
;
unsigned
flags_
;
unsigned
flags_
;
};
};
#pragma pack (pop)
//! GenericValue with UTF8 encoding
//! GenericValue with UTF8 encoding
typedef
GenericValue
<
UTF8
<>
>
Value
;
typedef
GenericValue
<
UTF8
<>
>
Value
;
...
...
include/rapidjson/filewritestream.h
View file @
ca9b2d18
...
@@ -48,7 +48,7 @@ public:
...
@@ -48,7 +48,7 @@ public:
void
PutN
(
char
c
,
size_t
n
)
{
void
PutN
(
char
c
,
size_t
n
)
{
size_t
avail
=
static_cast
<
size_t
>
(
bufferEnd_
-
current_
);
size_t
avail
=
static_cast
<
size_t
>
(
bufferEnd_
-
current_
);
while
(
n
>
avail
)
{
while
(
n
>
avail
)
{
memset
(
current_
,
c
,
avail
);
std
::
memset
(
current_
,
c
,
avail
);
current_
+=
avail
;
current_
+=
avail
;
Flush
();
Flush
();
n
-=
avail
;
n
-=
avail
;
...
@@ -56,7 +56,7 @@ public:
...
@@ -56,7 +56,7 @@ public:
}
}
if
(
n
>
0
)
{
if
(
n
>
0
)
{
memset
(
current_
,
c
,
n
);
std
::
memset
(
current_
,
c
,
n
);
current_
+=
n
;
current_
+=
n
;
}
}
}
}
...
...
include/rapidjson/internal/dtoa.h
View file @
ca9b2d18
...
@@ -362,14 +362,14 @@ inline char* Prettify(char* buffer, int length, int k) {
...
@@ -362,14 +362,14 @@ inline char* Prettify(char* buffer, int length, int k) {
}
}
else
if
(
0
<
kk
&&
kk
<=
21
)
{
else
if
(
0
<
kk
&&
kk
<=
21
)
{
// 1234e-2 -> 12.34
// 1234e-2 -> 12.34
memmove
(
&
buffer
[
kk
+
1
],
&
buffer
[
kk
],
length
-
kk
);
std
::
memmove
(
&
buffer
[
kk
+
1
],
&
buffer
[
kk
],
length
-
kk
);
buffer
[
kk
]
=
'.'
;
buffer
[
kk
]
=
'.'
;
return
&
buffer
[
length
+
1
];
return
&
buffer
[
length
+
1
];
}
}
else
if
(
-
6
<
kk
&&
kk
<=
0
)
{
else
if
(
-
6
<
kk
&&
kk
<=
0
)
{
// 1234e-6 -> 0.001234
// 1234e-6 -> 0.001234
const
int
offset
=
2
-
kk
;
const
int
offset
=
2
-
kk
;
memmove
(
&
buffer
[
offset
],
&
buffer
[
0
],
length
);
std
::
memmove
(
&
buffer
[
offset
],
&
buffer
[
0
],
length
);
buffer
[
0
]
=
'0'
;
buffer
[
0
]
=
'0'
;
buffer
[
1
]
=
'.'
;
buffer
[
1
]
=
'.'
;
for
(
int
i
=
2
;
i
<
offset
;
i
++
)
for
(
int
i
=
2
;
i
<
offset
;
i
++
)
...
@@ -383,7 +383,7 @@ inline char* Prettify(char* buffer, int length, int k) {
...
@@ -383,7 +383,7 @@ inline char* Prettify(char* buffer, int length, int k) {
}
}
else
{
else
{
// 1234e30 -> 1.234e33
// 1234e30 -> 1.234e33
memmove
(
&
buffer
[
2
],
&
buffer
[
1
],
length
-
1
);
std
::
memmove
(
&
buffer
[
2
],
&
buffer
[
1
],
length
-
1
);
buffer
[
1
]
=
'.'
;
buffer
[
1
]
=
'.'
;
buffer
[
length
+
1
]
=
'e'
;
buffer
[
length
+
1
]
=
'e'
;
return
WriteExponent
(
kk
-
1
,
&
buffer
[
0
+
length
+
2
]);
return
WriteExponent
(
kk
-
1
,
&
buffer
[
0
+
length
+
2
]);
...
...
include/rapidjson/memorybuffer.h
View file @
ca9b2d18
...
@@ -68,7 +68,7 @@ typedef GenericMemoryBuffer<> MemoryBuffer;
...
@@ -68,7 +68,7 @@ typedef GenericMemoryBuffer<> MemoryBuffer;
//! Implement specialized version of PutN() with memset() for better performance.
//! Implement specialized version of PutN() with memset() for better performance.
template
<>
template
<>
inline
void
PutN
(
MemoryBuffer
&
memoryBuffer
,
char
c
,
size_t
n
)
{
inline
void
PutN
(
MemoryBuffer
&
memoryBuffer
,
char
c
,
size_t
n
)
{
memset
(
memoryBuffer
.
stack_
.
Push
<
char
>
(
n
),
c
,
n
*
sizeof
(
c
));
std
::
memset
(
memoryBuffer
.
stack_
.
Push
<
char
>
(
n
),
c
,
n
*
sizeof
(
c
));
}
}
}
// namespace rapidjson
}
// namespace rapidjson
...
...
include/rapidjson/rapidjson.h
View file @
ca9b2d18
...
@@ -45,8 +45,8 @@
...
@@ -45,8 +45,8 @@
different translation units of a single application.
different translation units of a single application.
*/
*/
#include <cstdlib> // malloc(), realloc(), free()
#include <cstdlib> // malloc(), realloc(), free()
, size_t
#include <cstring> // mem
cpy
()
#include <cstring> // mem
set(), memcpy(), memmove(), memcmp
()
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_NO_INT64DEFINE
// RAPIDJSON_NO_INT64DEFINE
...
@@ -248,6 +248,11 @@ typedef unsigned SizeType;
...
@@ -248,6 +248,11 @@ typedef unsigned SizeType;
}
// namespace rapidjson
}
// namespace rapidjson
#endif
#endif
// always import std::size_t to rapidjson namespace
namespace
rapidjson
{
using
std
::
size_t
;
}
// namespace rapidjson
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// RAPIDJSON_ASSERT
// RAPIDJSON_ASSERT
...
...
include/rapidjson/stringbuffer.h
View file @
ca9b2d18
...
@@ -71,7 +71,7 @@ typedef GenericStringBuffer<UTF8<> > StringBuffer;
...
@@ -71,7 +71,7 @@ typedef GenericStringBuffer<UTF8<> > StringBuffer;
//! Implement specialized version of PutN() with memset() for better performance.
//! Implement specialized version of PutN() with memset() for better performance.
template
<>
template
<>
inline
void
PutN
(
GenericStringBuffer
<
UTF8
<>
>&
stream
,
char
c
,
size_t
n
)
{
inline
void
PutN
(
GenericStringBuffer
<
UTF8
<>
>&
stream
,
char
c
,
size_t
n
)
{
memset
(
stream
.
stack_
.
Push
<
char
>
(
n
),
c
,
n
*
sizeof
(
c
));
std
::
memset
(
stream
.
stack_
.
Push
<
char
>
(
n
),
c
,
n
*
sizeof
(
c
));
}
}
}
// namespace rapidjson
}
// namespace rapidjson
...
...
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