aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctimeline.c12
-rw-r--r--ctimeline.h8
-rw-r--r--ui-common.c8
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("<html>\n");
printf("<head>\n");
- printf("<title>%s</title>\n", ctx.head_title);
- printf("<link rel='stylesheet' href='%s'>\n", ctx.css);
+ printf("<title>%s</title>\n", ctx.head_title->s);
+ printf("<link rel='stylesheet' href='%s'>\n", ctx.css->s);
printf("</head>\n");
printf("</body>\n");
}
@@ -27,12 +27,12 @@ void print_document_header()
printf("<tr>\n");
printf(
- "<td><p class='header'>%s</p></td>\n", ctx.header_title);
+ "<td><p class='header'>%s</p></td>\n", ctx.header_title->s);
printf("</tr>\n");
printf("<tr class='sub_text'>\n");
printf(
- "<td>%s</td>\n", ctx.header_desc);
+ "<td>%s</td>\n", ctx.header_desc->s);
printf("</tr>\n");
printf("</table>\n");