diff options
Diffstat (limited to 'src/bindings.c')
-rw-r--r-- | src/bindings.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bindings.c b/src/bindings.c index eb9710c..b02911b 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -5,6 +5,7 @@ #include "honeysuckle.h" #include "md4c-html.h" #include "bindings.h" +#include "logging.h" struct concat_buffer { char *buf; @@ -15,6 +16,7 @@ struct concat_buffer { static void md_callback(const MD_CHAR *html, MD_SIZE size, void *data) { + argent_log(TRACE, "begin md_callback()"); struct concat_buffer *d = data; if (!d->ok) @@ -24,6 +26,7 @@ static void md_callback(const MD_CHAR *html, MD_SIZE size, void *data) char *new_buf = realloc(d->buf, d->size * 2); if (new_buf == NULL) { // failed to allocate memory, abort! + argent_log(WARN, "failed to properly allocate memory for html buffer!"); d->ok = false; return; } @@ -34,13 +37,17 @@ static void md_callback(const MD_CHAR *html, MD_SIZE size, void *data) memcpy((d->buf) + d->index, html, size); d->index += size; + + argent_log(TRACE, "finish md_callback()"); } int markdown(lua_State *L) { + argent_log(DEBUG, "begin markdown parsing"); char *markdown_buffer; hs_parse_args(L, hs_str(markdown_buffer)); size_t len = strlen(markdown_buffer); + argent_log(TRACE, "markdown input (%ld bytes): %s", len, markdown_buffer); unsigned int md_flags = MD_FLAG_TABLES | MD_FLAG_STRIKETHROUGH | MD_FLAG_UNDERLINE; @@ -50,6 +57,7 @@ int markdown(lua_State *L) data.index = 0; data.ok = true; + argent_log(TRACE, "call md_html()"); // fill out the buffer int error = md_html(markdown_buffer, len, md_callback, &data, md_flags, 0); if (error) @@ -60,9 +68,11 @@ int markdown(lua_State *L) data.buf[data.index] = 0; + argent_log(TRACE, "finished HTML buffer (%d bytes, %d chars): %s", + data.size, data.index, data.buf); lua_pushstring(L, data.buf); - free(data.buf); - + + argent_log(DEBUG, "finish markdown parsing"); return 1; } |