summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/render.c19
-rw-r--r--src/render.h1
2 files changed, 11 insertions, 9 deletions
diff --git a/src/render.c b/src/render.c
index f374b1c..c076e17 100644
--- a/src/render.c
+++ b/src/render.c
@@ -1,10 +1,10 @@
#include <stdlib.h>
#include "buffer.h"
-#include "chunk.h"
#include "cmark.h"
#include "utf8.h"
#include "render.h"
#include "node.h"
+#include "cmark_ctype.h"
static CMARK_INLINE void S_cr(cmark_renderer *renderer) {
if (renderer->need_cr < 1) {
@@ -26,7 +26,6 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap,
int i = 0;
int last_nonspace;
int len;
- cmark_chunk remainder = cmark_chunk_literal("");
int k = renderer->buffer->size - 1;
wrap = wrap && !renderer->no_linebreaks;
@@ -112,18 +111,22 @@ static void S_out(cmark_renderer *renderer, const char *source, bool wrap,
!renderer->begin_line && renderer->last_breakable > 0) {
// copy from last_breakable to remainder
- cmark_chunk_set_cstr(renderer->mem, &remainder,
- (char *)renderer->buffer->ptr +
- renderer->last_breakable + 1);
+ unsigned char *src = renderer->buffer->ptr +
+ renderer->last_breakable + 1;
+ bufsize_t remainder_len = renderer->buffer->size -
+ renderer->last_breakable - 1;
+ unsigned char *remainder =
+ (unsigned char *)renderer->mem->realloc(NULL, remainder_len);
+ memcpy(remainder, src, remainder_len);
// truncate at last_breakable
cmark_strbuf_truncate(renderer->buffer, renderer->last_breakable);
// add newline, prefix, and remainder
cmark_strbuf_putc(renderer->buffer, '\n');
cmark_strbuf_put(renderer->buffer, renderer->prefix->ptr,
renderer->prefix->size);
- cmark_strbuf_put(renderer->buffer, remainder.data, remainder.len);
- renderer->column = renderer->prefix->size + remainder.len;
- cmark_chunk_free(renderer->mem, &remainder);
+ cmark_strbuf_put(renderer->buffer, remainder, remainder_len);
+ renderer->column = renderer->prefix->size + remainder_len;
+ renderer->mem->free(remainder);
renderer->last_breakable = 0;
renderer->begin_line = false;
renderer->begin_content = false;
diff --git a/src/render.h b/src/render.h
index 0575340..15f6c2c 100644
--- a/src/render.h
+++ b/src/render.h
@@ -7,7 +7,6 @@ extern "C" {
#include <stdlib.h>
#include "buffer.h"
-#include "chunk.h"
typedef enum { LITERAL, NORMAL, TITLE, URL } cmark_escaping;