diff options
author | Alan D. Brunelle <alan.brunelle@hp.com> | 2009-02-13 12:43:45 -0500 |
---|---|---|
committer | Alan D. Brunelle <alan.brunelle@hp.com> | 2009-02-13 12:43:45 -0500 |
commit | c053af429559c8f4311cd773262ff223097cdcb3 (patch) | |
tree | e54213ccebb11d9dafce4d8376e4027983afb48d /btt/bno_dump.c | |
parent | 8f34184f8c7905bb929862d224a7c4969bc9190e (diff) | |
download | blktrace-c053af429559c8f4311cd773262ff223097cdcb3.tar.gz blktrace-c053af429559c8f4311cd773262ff223097cdcb3.tar.bz2 |
btt general cleanup plus valgrind clean
Lots of general clean up of code, getting interfaces across different
files to be similar (all are no alloc/free), and made it valgrind clean.
Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com
Diffstat (limited to 'btt/bno_dump.c')
-rw-r--r-- | btt/bno_dump.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/btt/bno_dump.c b/btt/bno_dump.c index 7f7680e..7365300 100644 --- a/btt/bno_dump.c +++ b/btt/bno_dump.c @@ -24,8 +24,6 @@ struct bno_dump { FILE *rfp, *wfp, *cfp; }; -static struct file_info *bno_dump_files = NULL; - static FILE *bno_dump_open(__u32 device, char rwc) { FILE *fp; @@ -40,11 +38,17 @@ static FILE *bno_dump_open(__u32 device, char rwc) if ((fp = my_fopen(oname, "w")) == NULL) perror(oname); else - add_file(&bno_dump_files, fp, oname); + add_file(fp, oname); return fp; } -void *bno_dump_init(__u32 device) +static inline void bno_dump_write(FILE *fp, struct io *iop) +{ + fprintf(fp, "%15.9lf %lld %lld\n", BIT_TIME(iop->t.time), + (long long)BIT_START(iop), (long long)BIT_END(iop)); +} + +void *bno_dump_alloc(__u32 device) { struct bno_dump *bdp; @@ -58,35 +62,21 @@ void *bno_dump_init(__u32 device) return bdp; } -void bno_dump_exit(void *param) +void bno_dump_free(void *param) { - /* - * Associated files will be auto-cleaned by bno_dump_clean - */ free(param); } -static inline void bno_dump_write(FILE *fp, struct io *iop) -{ - fprintf(fp, "%15.9lf %lld %lld\n", - BIT_TIME(iop->t.time), - (long long)BIT_START(iop), (long long)BIT_END(iop)); -} - void bno_dump_add(void *handle, struct io *iop) { -# define RW_FP(bdp, iop) (IOP_READ(iop) ? bdp->rfp : bdp->wfp) struct bno_dump *bdp = handle; if (bdp) { - if (RW_FP(bdp, iop)) - bno_dump_write(RW_FP(bdp, iop), iop); + FILE *fp = IOP_READ(iop) ? bdp->rfp : bdp->wfp; + + if (fp) + bno_dump_write(fp, iop); if (bdp->cfp) bno_dump_write(bdp->cfp, iop); } } - -void bno_dump_clean(void) -{ - clean_files(&bno_dump_files); -} |