cmark

My personal build of CMark ✏️

Commit
fe80f7b35fc168e0d1bb142a52073c6f0e1e9ef8
Parent
6403a37913828f69de52ebabf33499ced848641d
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Cast void pointers explicitly

Needed for C++ compatibility.

Diffstat

6 files changed, 16 insertions, 16 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 8 4 4
Modified src/buffer.c 6 3 3
Modified src/chunk.h 4 2 2
Modified src/cmark.c 8 4 4
Modified src/inlines.c 2 1 1
Modified src/references.c 4 2 2
diff --git a/src/blocks.c b/src/blocks.c
@@ -20,7 +20,7 @@ static node_block* make_block(int tag, int start_line, int start_column)
 {
 	node_block* e;
 
-	e = calloc(1, sizeof(*e));
+	e = (node_block *)calloc(1, sizeof(*e));
 	if(e != NULL) {
 		e->tag = tag;
 		e->open = true;
@@ -344,7 +344,7 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr)
 		if (!isspace(peek_at(input, pos))) {
 			return 0;
 		}
-		data = calloc(1, sizeof(*data));
+		data = (struct ListData *)calloc(1, sizeof(*data));
 		if(data == NULL) {
 			return 0;
 		} else {
@@ -369,7 +369,7 @@ static int parse_list_marker(chunk *input, int pos, struct ListData ** dataptr)
 			if (!isspace(peek_at(input, pos))) {
 				return 0;
 			}
-			data = calloc(1, sizeof(*data));
+			data = (struct ListData *)calloc(1, sizeof(*data));
 			if(data == NULL) {
 				return 0;
 			} else {
@@ -440,7 +440,7 @@ extern node_block *cmark_parse_document(const unsigned char *buffer, size_t len)
 	node_block *document;
 
 	while (buffer < end) {
-		const unsigned char *eol = memchr(buffer, '\n', end - buffer);
+		const unsigned char *eol = (unsigned char *)memchr(buffer, '\n', end - buffer);
 		offset = eol ? (eol - buffer) + 1 : eol - buffer;
 		cmark_process_line(parser, buffer, offset);
 		buffer += offset;
diff --git a/src/buffer.c b/src/buffer.c
@@ -60,7 +60,7 @@ int cmark_strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
 	/* round allocation up to multiple of 8 */
 	new_size = (new_size + 7) & ~7;
 
-	new_ptr = realloc(new_ptr, new_size);
+	new_ptr = (unsigned char *)realloc(new_ptr, new_size);
 
 	if (!new_ptr) {
 		if (mark_oom)
@@ -241,7 +241,7 @@ unsigned char *cmark_strbuf_detach(strbuf *buf)
 
 	if (buf->asize == 0 || buf->ptr == cmark_strbuf__oom) {
 		/* return an empty string */
-		return calloc(1, 1);
+		return (unsigned char *)calloc(1, 1);
 	}
 
 	cmark_strbuf_init(buf, 0);
@@ -273,7 +273,7 @@ int cmark_strbuf_cmp(const strbuf *a, const strbuf *b)
 
 int cmark_strbuf_strchr(const strbuf *buf, int c, int pos)
 {
-	const unsigned char *p = memchr(buf->ptr + pos, c, buf->size - pos);
+	const unsigned char *p = (unsigned char *)memchr(buf->ptr + pos, c, buf->size - pos);
 	if (!p)
 		return -1;
 
diff --git a/src/chunk.h b/src/chunk.h
@@ -51,7 +51,7 @@ static inline void cmark_chunk_trim(cmark_chunk *c)
 
 static inline int cmark_chunk_strchr(cmark_chunk *ch, int c, int offset)
 {
-	const unsigned char *p = memchr(ch->data + offset, c, ch->len - offset);
+	const unsigned char *p = (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
 	return p ? (int)(p - ch->data) : ch->len;
 }
 
@@ -59,7 +59,7 @@ static inline unsigned char *cmark_chunk_to_cstr(cmark_chunk *c)
 {
 	unsigned char *str;
 
-	str = calloc(c->len + 1, sizeof(*str));
+	str = (unsigned char *)calloc(c->len + 1, sizeof(*str));
     if(str != NULL) {
     	memcpy(str, c->data, c->len);
 	    str[c->len] = 0;
diff --git a/src/cmark.c b/src/cmark.c
@@ -76,7 +76,7 @@ void cmark_free_inlines(cmark_node_inl* e)
 
 inline cmark_node_inl *cmark_make_link(cmark_node_inl *label, unsigned char *url, unsigned char *title)
 {
-	cmark_node_inl* e = calloc(1, sizeof(*e));
+	cmark_node_inl* e = (cmark_node_inl *)calloc(1, sizeof(*e));
 	if(e != NULL) {
 		e->tag = CMARK_INL_LINK;
 		e->content.linkable.label = label;
@@ -110,7 +110,7 @@ inline cmark_node_inl* cmark_make_autolink(cmark_node_inl* label, chunk url, int
 
 inline cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents)
 {
-	cmark_node_inl * e = calloc(1, sizeof(*e));
+	cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
 	if(e != NULL) {
 		e->tag = t;
 		e->content.inlines = contents;
@@ -122,7 +122,7 @@ inline cmark_node_inl* cmark_make_inlines(int t, cmark_node_inl* contents)
 // Create an inline with a literal string value.
 inline cmark_node_inl* cmark_make_literal(int t, cmark_chunk s)
 {
-	cmark_node_inl * e = calloc(1, sizeof(*e));
+	cmark_node_inl * e = (cmark_node_inl *)calloc(1, sizeof(*e));
 	if(e != NULL) {
 		e->tag = t;
 		e->content.literal = s;
@@ -134,7 +134,7 @@ inline cmark_node_inl* cmark_make_literal(int t, cmark_chunk s)
 // Create an inline with no value.
 inline cmark_node_inl* cmark_make_simple(int t)
 {
-	cmark_node_inl* e = calloc(1, sizeof(*e));
+	cmark_node_inl* e = (cmark_node_inl *)calloc(1, sizeof(*e));
 	if(e != NULL) {
 		e->tag = t;
 		e->next = NULL;
diff --git a/src/inlines.c b/src/inlines.c
@@ -43,7 +43,7 @@ static unsigned char *bufdup(const unsigned char *buf)
 
 	if (buf) {
 		int len = strlen((char *)buf);
-		new = calloc(len + 1, sizeof(*new));
+		new = (unsigned char *)calloc(len + 1, sizeof(*new));
 		if(new != NULL) {
 			memcpy(new, buf, len + 1);
 		}
diff --git a/src/references.c b/src/references.c
@@ -82,7 +82,7 @@ extern void reference_create(reference_map *map, chunk *label, chunk *url, chunk
 	if (reflabel == NULL)
 		return;
 
-	ref = calloc(1, sizeof(*ref));
+	ref = (reference *)calloc(1, sizeof(*ref));
 	if(ref != NULL) {
 		ref->label = reflabel;
 		ref->hash = refhash(ref->label);
@@ -149,5 +149,5 @@ void reference_map_free(reference_map *map)
 
 reference_map *reference_map_new(void)
 {
-	return calloc(1, sizeof(reference_map));
+	return (reference_map *)calloc(1, sizeof(reference_map));
 }