json: don't copy strings while escaping#76
Merged
nashif merged 2 commits intozephyrproject-rtos:masterfrom May 8, 2017
mbolivar:json-escape-inplace
Merged
json: don't copy strings while escaping#76nashif merged 2 commits intozephyrproject-rtos:masterfrom mbolivar:json-escape-inplace
nashif merged 2 commits intozephyrproject-rtos:masterfrom
mbolivar:json-escape-inplace
Conversation
lpereira
approved these changes
May 4, 2017
lib/json/json.c
Outdated
Member
There was a problem hiding this comment.
Nitpick, but could be a for (; next != str; next--) instead. Can remove the last few lines in the loop body.
Contributor
Author
There was a problem hiding this comment.
I tried and failed to think of a way to do it without while(1) / break. The edge cases are a little tricky.
The way you suggest won't work if *len == 1 and the character at str[0] needs escaping, for example.
added 2 commits
May 4, 2017 09:47
Currently, json_escape() allocates a temporary buffer on the stack that's the size of the string being escaped. Stack space is precious and longer JSON strings can run into the hundreds of bytes, so re-implement this routine to escape in place. Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
These all pass. Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
Contributor
Author
|
Update:
|
lpereira
approved these changes
May 5, 2017
pfalcon
approved these changes
May 8, 2017
nashif
approved these changes
May 8, 2017
nashif
pushed a commit
that referenced
this pull request
Jun 29, 2021
- to get the update hal_nxp from PR #76 Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
CristXu
pushed a commit
that referenced
this pull request
Jul 4, 2021
- to get the update hal_nxp from PR #76 Signed-off-by: Lucien Zhao <lucien.zhao@nxp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-implement json_escape() with a version that doesn't make a copy of the input string. Add test cases.