From f93b7523121ef42f5133001ec7ce2347e3bbfecf Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 19 May 2021 08:11:29 +0000 Subject: ctimeline: change (char *) to (string *) for context information --- ctimeline.c | 12 ++++++++---- ctimeline.h | 8 ++++---- ui-common.c | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ctimeline.c b/ctimeline.c index 4bbb7bf..d27fca5 100644 --- a/ctimeline.c +++ b/ctimeline.c @@ -14,10 +14,10 @@ struct ctimeline_context ctx; // from ctimeline.h static void prepare_context() { memset(&ctx, 0, sizeof(ctx)); - ctx.head_title = "Timeline browser"; - ctx.css = "static/ctimeline.css"; - ctx.header_title = "CTimeline"; - ctx.header_desc = "Web frontend for timelines written in C"; + ctx.head_title = string_alloc(NULL, "Timeline browser"); + ctx.css = string_alloc(NULL, "static/ctimeline.css"); + ctx.header_title = string_alloc(NULL, "CTimeline"); + ctx.header_desc = string_alloc(NULL, "Web frontend for timelines written in C"); ctx.branches.list = NULL; ctx.branches.count = 0; @@ -31,6 +31,10 @@ static void prepare_context() */ static void forget_context() { + string_release(ctx.head_title); + string_release(ctx.css); + string_release(ctx.header_title); + string_release(ctx.header_desc); free(ctx.branches.list); } diff --git a/ctimeline.h b/ctimeline.h index edd5062..36564dc 100644 --- a/ctimeline.h +++ b/ctimeline.h @@ -20,11 +20,11 @@ struct ctimeline_branch_list { }; struct ctimeline_context { - char *head_title; - char *css; + string *head_title; + string *css; // char *favicon; - char *header_title; - char *header_desc; + string *header_title; + string *header_desc; struct ctimeline_branch_list branches; struct ctimeline_branch *cur_branch; diff --git a/ui-common.c b/ui-common.c index 66ad5f7..87bae9a 100644 --- a/ui-common.c +++ b/ui-common.c @@ -13,8 +13,8 @@ void print_document_start() { printf("\n"); printf("\n"); - printf("%s\n", ctx.head_title); - printf("\n", ctx.css); + printf("%s\n", ctx.head_title->s); + printf("\n", ctx.css->s); printf("\n"); printf("\n"); } @@ -27,12 +27,12 @@ void print_document_header() printf("\n"); printf( - "

%s

\n", ctx.header_title); + "

%s

\n", ctx.header_title->s); printf("\n"); printf("\n"); printf( - "%s\n", ctx.header_desc); + "%s\n", ctx.header_desc->s); printf("\n"); printf("\n"); -- cgit v1.2.3-18-g5258