summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorchenzizhan <[email protected]>2023-09-15 18:14:26 +0800
committerchenzizhan <[email protected]>2023-09-15 18:14:26 +0800
commit1a432f86f6ac743735a51f513e8b0d71ff11e778 (patch)
treefedf9c418ab883a5de95a964bef23582eefe6ae8 /src/utils
parent6e5d010519ac5b2512367e1582f253bc0cc53297 (diff)
stash4.3.0-4.3.4(python api)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/very_fast_json_writer.c9
-rw-r--r--src/utils/very_fast_json_writer.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/utils/very_fast_json_writer.c b/src/utils/very_fast_json_writer.c
index df2bf01..e512b78 100644
--- a/src/utils/very_fast_json_writer.c
+++ b/src/utils/very_fast_json_writer.c
@@ -131,6 +131,15 @@ void json_writer_finish(struct json_writer *writer, char **result, size_t *resul
free(writer);
}
+const char *json_writer_unwrap(const struct json_writer *writer)
+{
+ if (writer->cursor == 0) {
+ return NULL;
+ }
+
+ return writer->buffer;
+}
+
void json_writer_object_item(struct json_writer *writer, const char *key, struct json_writer *writer_in)
{
json_writer_str_item(writer, key, strlen(key));
diff --git a/src/utils/very_fast_json_writer.h b/src/utils/very_fast_json_writer.h
index ec7b858..912a580 100644
--- a/src/utils/very_fast_json_writer.h
+++ b/src/utils/very_fast_json_writer.h
@@ -21,6 +21,7 @@ void json_writer_double_field(struct json_writer *writer, const char *key, doubl
void json_writer_longlong_field(struct json_writer *writer, const char *key, long long value);
void json_writer_object_item(struct json_writer *writer, const char *key, struct json_writer *writer_in);
void json_writer_finish(struct json_writer *writer, char **result, size_t *result_len);
+const char *json_writer_unwrap(const struct json_writer *writer);
#ifdef __cplusplus
}