src/cx/json.h

changeset 1013
add8358fc3c3
parent 1012
21884374edbb
child 1033
e3009345984b
--- 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.

mercurial