From: Michael Göhler Date: Sat, 8 Nov 2014 13:36:47 +0000 (+0100) Subject: beautifying some variable names and function calls X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=3ee3024232ec7ce4327293afd3f259c0179956ac;p=smdp.git beautifying some variable names and function calls --- diff --git a/include/markdown.h b/include/markdown.h index b803f81..f38a646 100644 --- a/include/markdown.h +++ b/include/markdown.h @@ -32,6 +32,8 @@ * function: next_slide to extend a linked list of type slide by one element * function: new_line to initialize a new linked list of type line * function: next_line to extend a linked list of type line by one element + * function: free_line to free a line elements memory + * function: free_deck to free a deck's memory * */ @@ -82,6 +84,7 @@ line_t *next_line(line_t *prev); slide_t *new_slide(); slide_t *next_slide(slide_t *prev); deck_t *new_deck(); +void free_line(line_t *l); void free_deck(deck_t *); #endif // !defined( MARKDOWN_H ) diff --git a/src/markdown.c b/src/markdown.c index 2db9d68..22ebdbf 100644 --- a/src/markdown.c +++ b/src/markdown.c @@ -62,26 +62,26 @@ deck_t *new_deck() { return x; } -void free_line(line_t *l) { - line_t *n; - while (l) { - n = l->next; - cstring_delete(l->text); - free(l); - l = n; +void free_line(line_t *line) { + line_t *next; + while (line) { + next = line->next; + (line->text->delete)(line->text); + free(line); + line = next; } } void free_deck(deck_t *deck) { - slide_t *s, *t; + slide_t *slide, *next; if (deck == NULL) return; - s = deck->slide; - while (s) { - free_line(s->line); - t = s->next; - free(s); - s = t; + slide = deck->slide; + while (slide) { + free_line(slide->line); + next = slide->next; + free(slide); + slide = next; } free_line(deck->header); free(deck); diff --git a/src/parser.c b/src/parser.c index c85af8c..9721bd4 100644 --- a/src/parser.c +++ b/src/parser.c @@ -161,7 +161,7 @@ deck_t *markdown_load(FILE *input) { } } } - cstring_delete(text); + (text->delete)(text); slide->lines = lc; deck->slides = sc;