v7 icon indicating copy to clipboard operation
v7 copied to clipboard

Update v7_stringify() to return length and v7_parse_json() to accept a length

Open swisspol opened this issue 10 years ago • 1 comments

v7_stringify() should have a way to return the length so that calling strlen() is not needed and v7_parse_json() should accept an optional length parameter (set to ~0 if unused).

This would optimize dealing with non-NUL terminated strings and reduce the number of string copies needed when interfacing v7 with the outside world.

swisspol avatar Dec 19 '15 20:12 swisspol

Actually, looking at the source, I'm wondering if there's not a bug today in v7_parse_json_file(): it calls exec_file() which reads the file and its size and then passes both to i_exec(), which in turn calls parse() which doesn't take a size parameter anymore. Does parse() assumes src is NUL-terminated? If so, this would not work when used from v7_parse_json_file().

swisspol avatar Dec 19 '15 20:12 swisspol