# HG changeset patch # User Mike Becker # Date 1734266648 -3600 # Node ID add8358fc3c34bf38ae86de98817a475b152fe62 # Parent 21884374edbb2e16703ca3f2c73c14e3a34bf943 add cxJsonReset() and cxPropertiesReset() relates to #431 diff -r 21884374edbb -r add8358fc3c3 src/cx/json.h --- a/src/cx/json.h Sun Dec 15 12:19:21 2024 +0100 +++ b/src/cx/json.h Sun Dec 15 13:44:08 2024 +0100 @@ -436,6 +436,21 @@ void cxJsonDestroy(CxJson *json); /** + * Destroys and re-initializes the json interface. + * + * You might want to use this, to reset the parser after + * encountering a syntax error. + * + * @param json the json interface + */ +cx_attr_nonnull +static inline void cxJsonReset(CxJson *json) { + const CxAllocator *allocator = json->allocator; + cxJsonDestroy(json); + cxJsonInit(json, allocator); +} + +/** * Adds more data to the input buffer. * * The data will be copied. diff -r 21884374edbb -r add8358fc3c3 src/cx/properties.h --- a/src/cx/properties.h Sun Dec 15 12:19:21 2024 +0100 +++ b/src/cx/properties.h Sun Dec 15 13:44:08 2024 +0100 @@ -363,6 +363,21 @@ void cxPropertiesDestroy(CxProperties *prop); /** + * Destroys and re-initializes the properties interface. + * + * You might want to use this, to reset the parser after + * encountering a syntax error. + * + * @param prop the properties interface + */ +cx_attr_nonnull +static inline void cxPropertiesReset(CxProperties *prop) { + CxPropertiesConfig config = prop->config; + cxPropertiesDestroy(prop); + cxPropertiesInit(prop, config); +} + +/** * Initialize a properties parser with the default configuration. * * @param prop the properties interface