ssnail

crappy and opinionated static site generator
git clone https://git.e1e0.net/ssnail.git
Log | Files | Refs | README | LICENSE

commit c4bcb9123cfa7c8cdaa69e87c37ce67fc8cab59b
parent 2142d4ed250c5b452a7a9c342af513bcf1b32fec
Author: Paco Esteban <paco@e1e0.net>
Date:   Tue, 30 Jun 2020 14:44:11 +0200

consistent use of strdup on gen_html

Diffstat:
Mssnail.c | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/ssnail.c b/ssnail.c @@ -211,19 +211,19 @@ gen_html(struct article *a) /* set default values for metadata */ if ((a->title = strdup("")) == NULL) { - error = ssnail_error_from_errno("malloc def title"); + error = ssnail_error_from_errno("def title"); goto out; } if ((a->author = strdup("")) == NULL) { - error = ssnail_error_from_errno("malloc def author"); + error = ssnail_error_from_errno("def author"); goto out; } if ((a->date = strdup("")) == NULL) { - error = ssnail_error_from_errno("malloc def date"); + error = ssnail_error_from_errno("def date"); goto out; } if ((a->type = strdup("page")) == NULL) { - error = ssnail_error_from_errno("malloc def type"); + error = ssnail_error_from_errno("def type"); goto out; } @@ -231,29 +231,29 @@ gen_html(struct article *a) TAILQ_FOREACH(md, &mq, entries) { if (strcmp(md->key, "title") == 0 ) { free(a->title); - if (asprintf(&a->title, "%s", md->value) == -1) { - error = ssnail_error_msg(2, "malloc title"); + if ((a->title = strdup(md->value)) == NULL) { + error = ssnail_error_from_errno("title"); goto out; } } if (strcmp(md->key, "author") == 0 ) { free(a->author); - if (asprintf(&a->author, "%s", md->value) == -1) { - error = ssnail_error_msg(2, "malloc author"); + if ((a->author = strdup(md->value)) == NULL) { + error = ssnail_error_from_errno("author"); goto out; } } if (strcmp(md->key, "date") == 0 ) { free(a->date); - if (asprintf(&a->date, "%s", md->value) == -1) { - error = ssnail_error_msg(2, "malloc date"); + if ((a->date = strdup(md->value)) == NULL) { + error = ssnail_error_from_errno("date"); goto out; } } if (strcmp(md->key, "type") == 0 ) { free(a->type); - if (asprintf(&a->type, "%s", md->value) == -1) { - error = ssnail_error_msg(2, "malloc type"); + if ((a->type = strdup(md->value)) == NULL) { + error = ssnail_error_from_errno("type"); goto out; } }