1ae7da004baa664dbbfaa2a7b8bf4b44001f18aa
ceisenhart
  Tue Jun 3 19:50:40 2014 -0700
Removed memory leak, fixed some stylistic errors
diff --git src/utils/bamToFastq/bamToFastq.c src/utils/bamToFastq/bamToFastq.c
index 1c14f2a..a694bf3 100644
--- src/utils/bamToFastq/bamToFastq.c
+++ src/utils/bamToFastq/bamToFastq.c
@@ -1,76 +1,80 @@
-/* bamToFastq - converts a BAM file to Fastq. */
+/* bamToFastq - Converts a bam file to fastq format. */
 
 /* Copyright (C) 2014 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 #include "common.h"
 #include "linefile.h"
 #include "hash.h"
 #include "options.h"
 #include "bamFile.h"
 #include "fq.h"
 
 void usage()
 /* Explain usage and exit. */
 {
 errAbort(
-  "bamToFastq - converts a BAM file to Fastq\n"
+  "bamToFastq - Converts a bam file to fastq format.\n"
   "usage:\n"
   "   bamToFastq input.bam output.fastq\n"
   "options:\n"
   "   "
   );
 }
 
 /* Command line validation table. */
 static struct optionSpec options[] = {
    {NULL, 0},
 };
 
 void fixQuality(struct fq *seq)
-/* The bam quality reader returns a format that is not FASTQ. */
+/* The bam quality reader returns a format that is not fastq. */
 /* This function updates the bam quality to a fastq quality. */
 {
 int size = strlen(seq->dna);
 int i = 0;
 for (i = 0; i < size; ++i)
     {
     seq->quality[i] += 33;
     }
 seq->quality[size] = '\0';
 }
 
 void bamToFastq(char *inBam, char *outFastq)
-/* bamToFastq - converts a BAM file to Fastq. */
+/* bamToFastq - converts a bam file to Fastq. */
 {
 samfile_t *in = bamMustOpenLocal(inBam, "rb", NULL);
-/* Open up the BAM input  and a fastq sequence */
+/* Open up the bam input  and a fastq sequence */
 FILE *f = mustOpen(outFastq, "w");
 bam1_t one;
 ZeroVar(&one);	// This seems to be necessary!
 struct fq seq = {};
 for (;;)
     {
     if (samread(in, &one) < 0)
 	{
 	break;
 	}
     seq.header = catTwoStrings("@",bam1_qname(&one));
     seq.dna = bamGetQuerySequence(&one, TRUE);
     seq.quality = bamGetQueryQuals(&one, TRUE);
-    /* enter in the required fastqSeq values */
+    /* Enter in the required fq values. */
     fixQuality(&seq); 
     fqWriteNext(&seq, f);
-    /* print the fasqSeq to file */
+    /* Print the fq to file. */
+    freez(&seq.header);
+    freez(&seq.dna);
+    freez(&seq.quality);
     }
+
 samclose(in);
 }
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 optionInit(&argc, argv, options);
 if (argc != 3)
     usage();
 bamToFastq(argv[1],argv[2]);
 return 0;
 }