cmark

My personal build of CMark ✏️

Commit
f39eaefb651064ea6b4b8f030ec98f98c94fe95a
Parent
8e11c6d7a2f43bd507cc0349843c6fde8392eccb
Author
Vicent Marti <tanoku@gmail.com>
Date

node: Memory diet

Reduce the storage size for the `cmark_code` struct

Diffstat

2 files changed, 4 insertions, 5 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 2 1 1
Modified src/node.h 7 3 4
diff --git a/src/blocks.c b/src/blocks.c
@@ -897,7 +897,7 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
                              parser->first_nonspace + 1);
       (*container)->as.code.fenced = true;
       (*container)->as.code.fence_char = peek_at(input, parser->first_nonspace);
-      (*container)->as.code.fence_length = matched;
+      (*container)->as.code.fence_length = (matched > 255) ? 255 : matched;
       (*container)->as.code.fence_offset =
           (int8_t)(parser->first_nonspace - parser->offset);
       (*container)->as.code.info = cmark_chunk_literal("");
diff --git a/src/node.h b/src/node.h
@@ -25,11 +25,10 @@ typedef struct {
 typedef struct {
   cmark_chunk info;
   cmark_chunk literal;
-  int fence_length;
-  /* fence_offset must be 0-3, so we can use int8_t */
-  int8_t fence_offset;
+  uint8_t fence_length;
+  uint8_t fence_offset;
   unsigned char fence_char;
-  bool fenced;
+  int8_t fenced;
 } cmark_code;
 
 typedef struct {