annotate accumulator_test.cpp @ 507:e7fd50483311

Free bits of the datum constructed in audioDB::query. We're not quite safe: error calls between allocation of some of these bits and pieces and their use will cause failure... but not freeing things here is definitely wrong.
author mas01cr
date Tue, 13 Jan 2009 21:37:10 +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 }