annotate status.cpp @ 497:9d8aee621afb api-inversion

More libtests fixups. Include audiodb_close() calls everywhere (whoops). Add the facility to run tests under valgrind. Unfortunately the error-exitcode flag doesn't actually cause an error exit if the only thing wrong is memory leaks, but it will if there are actual memory errors, which is a start.
author mas01cr
date Sat, 10 Jan 2009 16:07:43 +0000
parents 62a0515f59be
children
rev   line source
mas01cr@395 1 #include "audioDB.h"
mas01cr@395 2 extern "C" {
mas01cr@395 3 #include "audioDB_API.h"
mas01cr@402 4 #include "audioDB-internals.h"
mas01cr@395 5 }
mas01cr@395 6
mas01cr@395 7 int audiodb_status(adb_t *adb, adb_status_t *status) {
mas01cr@395 8 /* FIXME: it would be nice to be able to test for "is this database
mas01cr@395 9 pointer valid", but at the moment we punt that to memory
mas01cr@395 10 discipline. */
mas01cr@395 11
mas01cr@395 12 unsigned dudCount = 0;
mas01cr@395 13 unsigned nullCount = 0;
mas01cr@395 14
mas01cr@395 15 for(unsigned k = 0; k < adb->header->numFiles; k++) {
mas01cr@395 16 /* FIXME: this bare "16" here reveals a problem (or maybe two).
mas01cr@395 17 * 16 here means the default value of the sequenceLength parameter
mas01cr@395 18 * initializer (both in C++ and corresponding to the "-l" or
mas01cr@395 19 * "--sequencelength" command-line argument).
mas01cr@395 20 *
mas01cr@395 21 * The problem is that the API as currently designed provides no
mas01cr@395 22 * way to pass that information in to this routine; there's no
mas01cr@395 23 * input parameter; nor is there in the SOAP version of this
mas01cr@395 24 * query. However, there /is/ a way to pass that information on
mas01cr@395 25 * the command-line -- though that codepath is completely
mas01cr@395 26 * untested. I can see that it might be useful to provide this
mas01cr@395 27 * information, but at present it's probably completely unused, so
mas01cr@395 28 * the compromise for now is to hardwire the 16.
mas01cr@395 29 */
mas01cr@432 30 if((*adb->track_lengths)[k] < 16) {
mas01cr@395 31 dudCount++;
mas01cr@432 32 if(!(*adb->track_lengths)[k]) {
mas01cr@395 33 nullCount++;
mas01cr@395 34 }
mas01cr@395 35 }
mas01cr@395 36 }
mas01cr@395 37
mas01cr@395 38 status->numFiles = adb->header->numFiles;
mas01cr@395 39 status->dim = adb->header->dim;
mas01cr@395 40 status->length = adb->header->length;
mas01cr@395 41 status->dudCount = dudCount;
mas01cr@395 42 status->nullCount = nullCount;
mas01cr@395 43 status->flags = adb->header->flags;
mas01cr@395 44 status->data_region_size = adb->header->timesTableOffset - adb->header->dataOffset;
mas01cr@395 45
mas01cr@395 46 return 0;
mas01cr@395 47 }
mas01cr@395 48