annotate accumulator_test.cpp @ 601:82d23418d867

Fix some fd leaks in the command-line binary Strictly speaking, they're not really leaks, because the only codepath that suffers from these leaks exits immediately afterwards. On the other hand, this fix makes valgrind on e.g. tests/0025 happier, going from 5 errors to none.
author mas01cr
date Fri, 14 Aug 2009 16:39:32 +0000
parents 342822c2d49a
children
rev   line source
mas01cr@498 1 #include "audioDB.h"
mas01cr@498 2 extern "C" {
mas01cr@498 3 #include "audioDB_API.h"
mas01cr@498 4 }
mas01cr@498 5 #include "audioDB-internals.h"
mas01cr@498 6
mas01cr@498 7 #include "accumulators.h"
mas01cr@498 8
mas01cr@498 9 static NearestAccumulator<adb_result_dist_lt> *foo = new NearestAccumulator<adb_result_dist_lt>();
mas01cr@498 10
mas01cr@498 11 int main() {
mas01cr@498 12 adb_result_t r;
mas01cr@498 13 r.key = "hello";
mas01cr@498 14 r.ipos = 0;
mas01cr@498 15 r.qpos = 0;
mas01cr@498 16 r.dist = 3;
mas01cr@498 17 foo->add_point(&r);
mas01cr@498 18 r.ipos = 1;
mas01cr@498 19 r.dist = 2;
mas01cr@498 20 foo->add_point(&r);
mas01cr@498 21 r.qpos = 1;
mas01cr@498 22 foo->add_point(&r);
mas01cr@498 23
mas01cr@498 24 adb_query_results_t *rs;
mas01cr@498 25 rs = foo->get_points();
mas01cr@498 26 for (unsigned int k = 0; k < rs->nresults; k++) {
mas01cr@498 27 r = rs->results[k];
mas01cr@498 28 printf("%s: %f %u %u\n", r.key, r.dist, r.qpos, r.ipos);
mas01cr@498 29 }
mas01cr@498 30 free(rs->results);
mas01cr@498 31 free(rs);
mas01cr@498 32 delete foo;
mas01cr@498 33 return 1;
mas01cr@498 34 }