aboutsummaryrefslogtreecommitdiffhomepage
path: root/forth
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-31 15:35:54 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-31 15:35:54 +0000
commit1d5aaa8ef65f312508e41ec458d4a6457f9cd39e (patch)
tree21219c95bd9b3816f1745f90f266211c4aff06fa /forth
parent5a1e79595f7d1f951fb777cb16ad730bae649c84 (diff)
fix memory leaks
git-svn-id: http://skia.googlecode.com/svn/trunk@1448 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'forth')
-rw-r--r--forth/Forth.cpp5
-rw-r--r--forth/ForthParser.h3
-rw-r--r--forth/SampleForth.cpp4
-rw-r--r--forth/StdWords.cpp1
4 files changed, 11 insertions, 2 deletions
diff --git a/forth/Forth.cpp b/forth/Forth.cpp
index 01ed204a4f..1df9dd81bd 100644
--- a/forth/Forth.cpp
+++ b/forth/Forth.cpp
@@ -277,6 +277,11 @@ ForthParser::ForthParser() : fDict(4096) {
}
ForthParser::~ForthParser() {
+ SkTDict<ForthWord*>::Iter iter(fDict);
+ ForthWord* word;
+ while (iter.next(&word)) {
+ delete word;
+ }
}
static const char* parse_error(const char msg[]) {
diff --git a/forth/ForthParser.h b/forth/ForthParser.h
index 65a39a1a0f..706e95bf01 100644
--- a/forth/ForthParser.h
+++ b/forth/ForthParser.h
@@ -21,7 +21,8 @@ public:
void add(const char name[], size_t len, ForthWord* word) {
// SkString str(name, len);
// SkDebugf("add %s %p\n", str.c_str(), word);
- (void)fDict.set(name, len, word);
+ SkDEBUGCODE(bool isNewWord = )fDict.set(name, len, word);
+ SkASSERT(isNewWord);
}
ForthWord* find(const char name[], size_t len) const {
diff --git a/forth/SampleForth.cpp b/forth/SampleForth.cpp
index cfd1172d67..c0a0c75dc5 100644
--- a/forth/SampleForth.cpp
+++ b/forth/SampleForth.cpp
@@ -188,6 +188,10 @@ public:
#endif
}
+ virtual ~ForthView() {
+ SkDebugf("");
+ }
+
protected:
// overrides from SkEventSink
virtual bool onQuery(SkEvent* evt) {
diff --git a/forth/StdWords.cpp b/forth/StdWords.cpp
index 177dabd5b8..bd11180627 100644
--- a/forth/StdWords.cpp
+++ b/forth/StdWords.cpp
@@ -428,7 +428,6 @@ void ForthParser::addStdWords() {
this->add("fabs", 4, new fabs_ForthWord);
this->add("fmin", 4, new fmin_ForthWord);
this->add("fmax", 4, new fmax_ForthWord);
- this->add("fmax", 4, new fmax_ForthWord);
this->add("floor", 5, new floor_ForthWord);
this->add("ceil", 4, new ceil_ForthWord);
this->add("round", 5, new round_ForthWord);