aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Mikhirev2012-09-08 20:46:18 +0400
committerDmitry Mikhirev2012-09-08 20:46:18 +0400
commit50288082eb1489390a88a5f669a08d949e64f1ae (patch)
tree735fef81407f5bb8f5e9c5106aac379d03142cdc
parenteb388cb1036b8d8ff66e65cb4cd0f16351f273bb (diff)
downloadbrainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.gz
brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.bz2
brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.tar.xz
brainuino-50288082eb1489390a88a5f669a08d949e64f1ae.zip
fix memory leak
-rw-r--r--lcdprint.cpp3
-rw-r--r--lcdprint.h2
-rw-r--r--utf8.cpp5
-rw-r--r--utf8.h1
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++) {
diff --git a/lcdprint.h b/lcdprint.h
index 86dbfcc..bcc95f6 100644
--- a/lcdprint.h
+++ b/lcdprint.h
@@ -22,6 +22,6 @@
#include "utf8.h"
-size_t uprint (utf8, LiquidCrystal*);
+size_t uprint (char*, LiquidCrystal*);
#endif
diff --git a/utf8.cpp b/utf8.cpp
index ea28922..745e888 100644
--- a/utf8.cpp
+++ b/utf8.cpp
@@ -42,6 +42,11 @@ utf8::utf8 (char* input)
_index = 0;
}
+utf8::~utf8 ()
+{
+ free(string);
+}
+
int32_t utf8::get()
{
int32_t code;
diff --git a/utf8.h b/utf8.h
index dd4cd9b..d10557d 100644
--- a/utf8.h
+++ b/utf8.h
@@ -25,6 +25,7 @@
class utf8 {
public:
utf8(char* string);
+ ~utf8(void);
uint16_t chars;
uint16_t bytes;
int32_t get();