Skip to content

Conversation

@dan4thewin
Copy link
Contributor

Prior attempts to have the search function accept a const buffer and populate a non-const output pointer were problematic, generating MISRA violations. I settled for having the search function use non-const for both. This PR adds a variation of the search function that accepts a const buffer and populates a const output pointer.

* @param[in] query The object keys and array indexes to search for.
* @param[in] queryLength Length of the key.
* @param[out] outValue A pointer to receive the address of the value found.
* @param[out] outValue A pointer to receive the index of the value found.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call it outOffset or outValueOffset?

Copy link
Contributor Author

@dan4thewin dan4thewin Nov 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's already something of a convention that a size_t value or outValue is an index. I don't want to make sweeping changes for only a negligible benefit.

JSONTypes_t * outType )
{
JSONStatus_t ret;
size_t value;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to call it offset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See prior comment.

* @param[out] outType An enum indicating the JSON-specific type of the value.
*/
/* @[declare_json_searchtc] */
JSONStatus_t JSON_SearchTc( const char * buf,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a JSON_Search API, maybe add another JSON_SearchConst?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@dan4thewin dan4thewin merged commit f329562 into FreeRTOS:main Nov 24, 2020
@dan4thewin dan4thewin deleted the search-const branch November 24, 2020 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants