ext/redcarpet/markdown.c in redcarpet-2.0.0 vs ext/redcarpet/markdown.c in redcarpet-2.0.1

- old
+ new

@@ -1573,11 +1573,11 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size, int *flags) { struct buf *work = 0, *inter = 0; size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i; int in_empty = 0, has_inside_empty = 0; - int has_next_uli, has_next_oli; + size_t has_next_uli, has_next_oli; /* keeping track of the first indentation prefix */ while (orgpre < 3 && orgpre < size && data[orgpre] == ' ') orgpre++; @@ -1625,13 +1625,12 @@ has_next_uli = prefix_uli(data + beg + i, end - beg - i); has_next_oli = prefix_oli(data + beg + i, end - beg - i); /* checking for ul/ol switch */ if (in_empty && ( - ((*flags & MKD_LIST_ORDERED) && has_next_uli) || - (!(*flags & MKD_LIST_ORDERED) && has_next_oli) - )){ + ((*flags & MKD_LIST_ORDERED) && has_next_uli) || + (!(*flags & MKD_LIST_ORDERED) && has_next_oli))){ *flags |= MKD_LI_END; break; /* the following item must have same list type */ } /* checking for a new item */ @@ -1802,11 +1801,11 @@ i = 1; while (i < size && data[i] != '>' && data[i] != ' ') i++; if (i < size) - curtag = find_block_tag((char *)data + 1, i - 1); + curtag = find_block_tag((char *)data + 1, (int)i - 1); /* handling of special cases */ if (!curtag) { /* HTML comment, laxist form */ @@ -2359,11 +2358,11 @@ } void sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, struct sd_markdown *md) { - static const float MARKDOWN_GROW_FACTOR = 1.4f; +#define MARKDOWN_GROW(x) ((x) + ((x) >> 1)) struct buf *text; size_t beg, end; text = bufnew(64); @@ -2399,10 +2398,10 @@ beg = end; } /* pre-grow the output buffer to minimize allocations */ - bufgrow(ob, text->size * MARKDOWN_GROW_FACTOR); + bufgrow(ob, MARKDOWN_GROW(text->size)); /* second pass: actual rendering */ if (md->cb.doc_header) md->cb.doc_header(ob, md->opaque);