From 8c4061e17116703f424cc96d20fe8574606de277 Mon Sep 17 00:00:00 2001 From: Vlasta Vesely Date: Fri, 18 May 2018 10:09:06 +0200 Subject: [PATCH] transliteration: drop syllable chain when not needed --- syllable.c | 11 +++++++++++ syllable.h | 1 + transliteration.c | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/syllable.c b/syllable.c index 15eb039..ee3b9f9 100644 --- a/syllable.c +++ b/syllable.c @@ -69,3 +69,14 @@ char *syllable_chain_to_string(struct syllable *head) return buffer; } + +void syllable_chain_drop(struct syllable *head) +{ + struct syllable *walk = head, *next; + + while (walk) { + next = walk->next; + syllable_drop(walk); + walk = next; + } +} diff --git a/syllable.h b/syllable.h index b150405..a8ef94a 100644 --- a/syllable.h +++ b/syllable.h @@ -17,5 +17,6 @@ struct syllable *syllable_append(struct syllable *tail, const char *data); unsigned int syllable_chain_length(struct syllable *head); char *syllable_chain_to_string(struct syllable *head); +void syllable_chain_drop(struct syllable *head); #endif /* __SYLLABE_H */ diff --git a/transliteration.c b/transliteration.c index 92c6952..1b85cd2 100644 --- a/transliteration.c +++ b/transliteration.c @@ -85,7 +85,10 @@ char *transliterate_devanagari_to_latin(const char *text, apply_transliteration_filters(head, context->filters); - return syllable_chain_to_string(head); + tmp = syllable_chain_to_string(head); + syllable_chain_drop(head); + + return tmp; } void transliteration_context_drop(struct transliteration_context *context)