diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-10-24 19:17:35 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-10-24 19:17:35 -0700 |
commit | 2453227890fc744f9abcc87c472f0ce98de9e450 (patch) | |
tree | c71ea56cd678dbc8d2c50bc30d814015777d9367 /src/blocks.c | |
parent | 511e92f39fe9bdca51bea3ee0add95a6eca880f5 (diff) | |
parent | 2315882a431844394a2ec5300c03debf18713cb8 (diff) |
Merge branch 'tchetch-master'
Diffstat (limited to 'src/blocks.c')
-rw-r--r-- | src/blocks.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/blocks.c b/src/blocks.c index 18fcdc4..8d6fd06 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -19,15 +19,15 @@ static node_block* make_block(int tag, int start_line, int start_column) { node_block* e; - e = malloc(sizeof(node_block)); - memset(e, 0x0, sizeof(*e)); - - e->tag = tag; - e->open = true; - e->start_line = start_line; - e->start_column = start_column; - e->end_line = start_line; - strbuf_init(&e->string_content, 32); + e = calloc(1, sizeof(*e)); + if(e != NULL) { + e->tag = tag; + e->open = true; + e->start_line = start_line; + e->start_column = start_column; + e->end_line = start_line; + strbuf_init(&e->string_content, 32); + } return e; } @@ -310,14 +310,17 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr) if (!isspace(peek_at(input, pos))) { return 0; } - data = malloc(sizeof(struct ListData)); - data->marker_offset = 0; // will be adjusted later - data->list_type = bullet; - data->bullet_char = c; - data->start = 1; - data->delimiter = period; - data->tight = false; - + data = calloc(1, sizeof(*data)); + if(data == NULL) { + return 0; + } else { + data->marker_offset = 0; // will be adjusted later + data->list_type = bullet; + data->bullet_char = c; + data->start = 1; + data->delimiter = period; + data->tight = false; + } } else if (isdigit(c)) { int start = 0; @@ -332,13 +335,17 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr) if (!isspace(peek_at(input, pos))) { return 0; } - data = malloc(sizeof(struct ListData)); - data->marker_offset = 0; // will be adjusted later - data->list_type = ordered; - data->bullet_char = 0; - data->start = start; - data->delimiter = (c == '.' ? period : parens); - data->tight = false; + data = calloc(1, sizeof(*data)); + if(data == NULL) { + return 0; + } else { + data->marker_offset = 0; // will be adjusted later + data->list_type = ordered; + data->bullet_char = 0; + data->start = start; + data->delimiter = (c == '.' ? period : parens); + data->tight = false; + } } else { return 0; } |