From da357d5f6da0504b7b5048a3b64faa9ce87ae2f0 Mon Sep 17 00:00:00 2001 From: Charles Julian Knight Date: Fri, 19 Jul 2019 18:11:23 -0400 Subject: [PATCH] allow defining buffer size --- JsonStreamingParser.cpp | 2 +- JsonStreamingParser.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/JsonStreamingParser.cpp b/JsonStreamingParser.cpp index cfc71d1..be4cdb2 100644 --- a/JsonStreamingParser.cpp +++ b/JsonStreamingParser.cpp @@ -202,7 +202,7 @@ void JsonStreamingParser::parse(char c) { } void JsonStreamingParser::increaseBufferPointer() { - bufferPos = min(bufferPos + 1, BUFFER_MAX_LENGTH - 1); + bufferPos = min(bufferPos + 1, JSON_PARSER_BUFFER_MAX_LENGTH - 1); } void JsonStreamingParser::endString() { diff --git a/JsonStreamingParser.h b/JsonStreamingParser.h index 377e846..79cd425 100644 --- a/JsonStreamingParser.h +++ b/JsonStreamingParser.h @@ -49,7 +49,9 @@ See more at http://blog.squix.ch and https://github.com/squix78/json-streaming-p #define STACK_KEY 2 #define STACK_STRING 3 -#define BUFFER_MAX_LENGTH 512 +#ifndef JSON_PARSER_BUFFER_MAX_LENGTH +#define JSON_PARSER_BUFFER_MAX_LENGTH 512 +#endif class JsonStreamingParser { private: @@ -62,7 +64,7 @@ class JsonStreamingParser { boolean doEmitWhitespace = false; // fixed length buffer array to prepare for c code - char buffer[BUFFER_MAX_LENGTH]; + char buffer[JSON_PARSER_BUFFER_MAX_LENGTH]; int bufferPos = 0; char unicodeEscapeBuffer[10];