diff options
author | Dmitry Mikhirev | 2012-09-08 20:46:18 +0400 |
---|---|---|
committer | Dmitry Mikhirev | 2012-09-08 20:46:18 +0400 |
commit | 50288082eb1489390a88a5f669a08d949e64f1ae (patch) | |
tree | 735fef81407f5bb8f5e9c5106aac379d03142cdc | |
parent | eb388cb1036b8d8ff66e65cb4cd0f16351f273bb (diff) | |
download | brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.gz brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.bz2 brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.xz brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.zip |
fix memory leak
-rw-r--r-- | lcdprint.cpp | 3 | ||||
-rw-r--r-- | lcdprint.h | 2 | ||||
-rw-r--r-- | utf8.cpp | 5 | ||||
-rw-r--r-- | utf8.h | 1 |
4 files changed, 9 insertions, 2 deletions
diff --git a/lcdprint.cpp b/lcdprint.cpp index 7fa432d..8de92b3 100644 --- a/lcdprint.cpp +++ b/lcdprint.cpp @@ -21,11 +21,12 @@ #include "lcdprint.h" #include "font.h" -size_t uprint(utf8 str, LiquidCrystal *lcd) +size_t uprint(char* rawstr, LiquidCrystal *lcd) { int32_t ucode; int i, j; int numcodes = sizeof(charmap)/sizeof(charcode); + utf8 str = utf8(rawstr); char result[str.chars]; for (i = 0; i < str.chars; i++) { @@ -22,6 +22,6 @@ #include "utf8.h" -size_t uprint (utf8, LiquidCrystal*); +size_t uprint (char*, LiquidCrystal*); #endif @@ -42,6 +42,11 @@ utf8::utf8 (char* input) _index = 0; } +utf8::~utf8 () +{ + free(string); +} + int32_t utf8::get() { int32_t code; @@ -25,6 +25,7 @@ class utf8 { public: utf8(char* string); + ~utf8(void); uint16_t chars; uint16_t bytes; int32_t get(); |