diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2016-12-31 02:25:16 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-12-30 18:25:16 -0700 |
commit | 4fbe344df43ed7f60a3d3a53981088334cb709fc (patch) | |
tree | f7f8264d06cb31024f169fda11c5d72821510c51 /src/source_map.h | |
parent | c4c1d59ca29aceb1c5919908ac97d9476264fd96 (diff) |
Change types for source map offsets (#174)
* Improve strbuf guarantees
Introduce BUFSIZE_MAX macro and make sure that the strbuf implementation
can handle strings up to this size.
* Abort early if document size exceeds internal limit
* Change types for source map offsets
Switch to size_t for the public API, making the public headers
C89-compatible again.
Switch to bufsize_t internally, reducing memory usage and improving
performance on 32-bit platforms.
* Make parser return NULL on internal index overflow
Make S_parser_feed set an error and ignore subsequent chunks if the
total input document size exceeds an internal limit. Make
cmark_parser_finish return NULL if an error was encountered. Add
public API functions to retrieve error code and error message.
strbuf overflow in renderers and OOM in parser or renderers still
cause an abort.
Diffstat (limited to 'src/source_map.h')
-rw-r--r-- | src/source_map.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/source_map.h b/src/source_map.h index 619a073..dca5a9f 100644 --- a/src/source_map.h +++ b/src/source_map.h @@ -3,6 +3,7 @@ #include "cmark.h" #include "config.h" +#include "buffer.h" typedef struct _cmark_source_map { @@ -10,14 +11,14 @@ typedef struct _cmark_source_map cmark_source_extent *tail; cmark_source_extent *cursor; cmark_source_extent *next_cursor; - uint64_t cursor_offset; + bufsize_t cursor_offset; cmark_mem *mem; } cmark_source_map; struct cmark_source_extent { - uint64_t start; - uint64_t stop; + bufsize_t start; + bufsize_t stop; struct cmark_source_extent *next; struct cmark_source_extent *prev; cmark_node *node; @@ -29,20 +30,20 @@ cmark_source_map * source_map_new (cmark_mem *mem); void source_map_free (cmark_source_map *self); bool source_map_check (cmark_source_map *self, - uint64_t total_length); + bufsize_t total_length); void source_map_pretty_print (cmark_source_map *self); cmark_source_extent * source_map_append_extent(cmark_source_map *self, - uint64_t start, - uint64_t stop, + bufsize_t start, + bufsize_t stop, cmark_node *node, cmark_extent_type type); cmark_source_extent * source_map_insert_extent(cmark_source_map *self, cmark_source_extent *previous, - uint64_t start, - uint64_t stop, + bufsize_t start, + bufsize_t stop, cmark_node *node, cmark_extent_type type); @@ -52,11 +53,11 @@ cmark_source_extent * source_map_free_extent (cmark_source_map *self, cmark_source_extent * source_map_stitch_extent(cmark_source_map *self, cmark_source_extent *extent, cmark_node *node, - uint64_t total_length); + bufsize_t total_length); cmark_source_extent * source_map_splice_extent(cmark_source_map *self, - uint64_t start, - uint64_t stop, + bufsize_t start, + bufsize_t stop, cmark_node *node, cmark_extent_type type); |