From a599ccc4c8406c244454c5a0fedc547bf3b1405a Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 12 Apr 2015 09:25:14 +0200 Subject: mot-encoder: don't keep DLS input file open --- src/mot-encoder.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp index 0548614..f2115c0 100644 --- a/src/mot-encoder.cpp +++ b/src/mot-encoder.cpp @@ -235,7 +235,6 @@ char dlstext_prev[MAXDLS + 1]; // The DLS data groups std::deque > dlsdg; -static int dlsfd = 0; static int verbose = 0; @@ -878,17 +877,16 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset) int i; bool dlstext_new; - if (dlsfd != 0) { - close(dlsfd); - } - - dlsfd = open(dls_file, O_RDONLY); + int dlsfd = open(dls_file, O_RDONLY); if (dlsfd == -1) { fprintf(stderr, "mot-encoder Error: Cannot open dls file\n"); return; } dlslen = read(dlsfd, dlstext, MAXDLS); + + close(dlsfd); + dlstext[dlslen] = 0x00; // Remove trailing line breaks from the file -- cgit v1.2.3