summaryrefslogtreecommitdiffstats
path: root/common/common.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-30 20:28:32 +0100
committerwm4 <wm4@nowhere>2013-12-30 22:49:50 +0100
commit066ecfcbfb0b7120183338c5382e98c609a9d89a (patch)
treec03269c234b3b7edcc3bf19374134e341628dc42 /common/common.h
parent097fe8ea6fb25df68077c25c08f29fb57a9d2bd6 (diff)
downloadmpv-066ecfcbfb0b7120183338c5382e98c609a9d89a.tar.bz2
mpv-066ecfcbfb0b7120183338c5382e98c609a9d89a.tar.xz
common: simplify and optimize string escape parsing
This code is shared between input.conf parser and option parser. Until now, the performance didn't really matter. But I want to use this code for JSON parsing too, and since JSON will have to be parsed a lot, it should probably try to avoid realloc'ing too much. This commit moves parsing of C-style escaped strings into a common function, and allows using it in a way realloc can be completely avoided, if the already allocated buffer is large enough.
Diffstat (limited to 'common/common.h')
-rw-r--r--common/common.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/common.h b/common/common.h
index ae2fb8f2d5..7ae18d1b6f 100644
--- a/common/common.h
+++ b/common/common.h
@@ -76,6 +76,12 @@ bool mp_rect_intersection(struct mp_rect *rc, const struct mp_rect *rc2);
char *mp_append_utf8_buffer(char *buffer, uint32_t codepoint);
struct bstr;
-bool mp_parse_escape(struct bstr *code, char **str);
+
+void mp_append_utf8_bstr(void *talloc_ctx, struct bstr *buf, uint32_t codepoint);
+
+bool mp_append_escaped_string_noalloc(void *talloc_ctx, struct bstr *dst,
+ struct bstr *src);
+bool mp_append_escaped_string(void *talloc_ctx, struct bstr *dst,
+ struct bstr *src);
#endif /* MPLAYER_MPCOMMON_H */