Skip to content

Commit f5c9f3b

Browse files
committed
Switch to CrtAllocator, since MemoryPoolAllocator is broken on ARM
1 parent 904ba18 commit f5c9f3b

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

include/mapbox/geojsonvt/convert.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
namespace mapbox {
1111
namespace geojsonvt {
1212

13-
using JSValue = rapidjson::Value;
13+
// Use the CrtAllocator, because the MemoryPoolAllocator is broken on ARM
14+
// https://github.com/miloyip/rapidjson/issues/200
15+
// https://github.com/miloyip/rapidjson/issues/301
16+
// https://github.com/miloyip/rapidjson/issues/388
17+
using JSDocument = rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
18+
using JSValue = rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>;
1419

1520
class __attribute__((visibility("default"))) Convert {
1621
private:

src/convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void Convert::convertFeature(std::vector<ProjectedFeature>& features,
6262
Tags tags;
6363
if (feature.HasMember("properties") && feature["properties"].IsObject()) {
6464
const JSValue& properties = feature["properties"];
65-
rapidjson::Value::ConstMemberIterator itr = properties.MemberBegin();
65+
JSValue::ConstMemberIterator itr = properties.MemberBegin();
6666
for (; itr != properties.MemberEnd(); ++itr) {
6767
std::string key{ itr->name.GetString(), itr->name.GetStringLength() };
6868
switch (itr->value.GetType()) {

src/geojsonvt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ std::vector<ProjectedFeature> GeoJSONVT::convertFeatures(const std::string& data
201201

202202
uint32_t z2 = 1 << options.maxZoom; // 2^z
203203

204-
rapidjson::Document deserializedData;
204+
JSDocument deserializedData;
205205
deserializedData.Parse<0>(data.c_str());
206206

207207
if (deserializedData.HasParseError()) {

test/util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool operator==(const ProjectedRing& a, const ProjectedRing& b) {
121121
return true;
122122
}
123123

124-
std::vector<TileFeature> parseJSONTile(const rapidjson::Value& tile) {
124+
std::vector<TileFeature> parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>& tile) {
125125
std::vector<TileFeature> features;
126126
EXPECT_TRUE(tile.IsArray());
127127
for (rapidjson::SizeType k = 0; k < tile.Size(); ++k) {
@@ -205,7 +205,7 @@ std::vector<TileFeature> parseJSONTile(const rapidjson::Value& tile) {
205205
}
206206

207207
std::vector<TileFeature> parseJSONTile(const std::string& data) {
208-
rapidjson::Document d;
208+
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
209209
d.Parse<0>(data.c_str());
210210

211211
if (d.HasParseError()) {
@@ -219,7 +219,7 @@ std::vector<TileFeature> parseJSONTile(const std::string& data) {
219219

220220
std::map<std::string, std::vector<TileFeature>> parseJSONTiles(const std::string& data) {
221221
std::map<std::string, std::vector<TileFeature>> result;
222-
rapidjson::Document d;
222+
rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator> d;
223223
d.Parse<0>(data.c_str());
224224

225225
if (d.HasParseError()) {

test/util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ bool operator==(const TileFeature& a, const TileFeature& b);
2525
bool operator==(const ProjectedFeature& a, const ProjectedFeature& b);
2626
bool operator==(const ProjectedRing& a, const ProjectedRing& b);
2727

28-
std::vector<TileFeature> parseJSONTile(const rapidjson::Value& tile);
28+
std::vector<TileFeature> parseJSONTile(const rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>& tile);
2929
std::vector<TileFeature> parseJSONTile(const std::string& data);
3030
std::map<std::string, std::vector<TileFeature>> parseJSONTiles(const std::string& data);
3131

0 commit comments

Comments
 (0)