From fd2e0503068117d406a87b9a6d7d843b59289f59 Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Fri, 26 Apr 2013 11:34:07 -0700 Subject: [PATCH 1/2] fix warnings --- src/Topk.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Topk.cc b/src/Topk.cc index 8ad2113235..26f14c4fcb 100644 --- a/src/Topk.cc +++ b/src/Topk.cc @@ -178,7 +178,7 @@ bool TopkVal::DoSerialize(SerialInfo* info) const else assert(numElements == 0); - int i = 0; + uint64_t i = 0; std::list::const_iterator it = buckets.begin(); while ( it != buckets.end() ) { @@ -223,7 +223,7 @@ bool TopkVal::DoUnserialize(UnserialInfo* info) else assert(numElements == 0); - int i = 0; + uint64_t i = 0; while ( i < numElements ) { Bucket* b = new Bucket(); @@ -232,7 +232,7 @@ bool TopkVal::DoUnserialize(UnserialInfo* info) v &= UNSERIALIZE(&b->count); b->bucketPos = buckets.insert(buckets.end(), b); - for ( int j = 0; j < elements_count; j++ ) + for ( uint64_t j = 0; j < elements_count; j++ ) { Element* e = new Element(); v &= UNSERIALIZE(&e->epsilon); From 1accee41edb48f7ed162f879bdf593f505d84b5b Mon Sep 17 00:00:00 2001 From: Bernhard Amann Date: Fri, 26 Apr 2013 14:06:38 -0700 Subject: [PATCH 2/2] fix memory leaks --- src/Topk.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Topk.cc b/src/Topk.cc index 26f14c4fcb..116a4d3de4 100644 --- a/src/Topk.cc +++ b/src/Topk.cc @@ -26,12 +26,13 @@ Element::~Element() HashKey* TopkVal::GetHash(Val* v) const { TypeList* tl = new TypeList(v->Type()); - tl->Append(v->Type()); + tl->Append(v->Type()->Ref()); CompositeHash* topk_hash = new CompositeHash(tl); Unref(tl); HashKey* key = topk_hash->ComputeHash(v, 1); assert(key); + delete topk_hash; return key; } @@ -311,6 +312,7 @@ uint64_t TopkVal::getCount(Val* value) const return 0; } + delete key; return e->parent->count; } @@ -325,6 +327,7 @@ uint64_t TopkVal::getEpsilon(Val* value) const return 0; } + delete key; return e->epsilon; }