minor formatting
[flac.git] / src / test_libFLAC / metadata_manip.c
index b998822..159205b 100644 (file)
@@ -1,5 +1,5 @@
 /* test_libFLAC - Unit tester for libFLAC
- * Copyright (C) 2002  Josh Coalson
+ * Copyright (C) 2002,2003  Josh Coalson
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
 #include "FLAC/assert.h"
 #include "FLAC/file_decoder.h"
 #include "FLAC/metadata.h"
+#include "share/grabbag.h"
 #include <stdio.h>
 #include <stdlib.h> /* for malloc() */
 
@@ -176,7 +177,7 @@ static FLAC__bool compare_chain_(FLAC__Metadata_Chain *chain, unsigned current_p
                        return die_("getting block from iterator");
                }
 
-               if(!compare_block_(our_metadata_.blocks[i], block)) {
+               if(!mutils__compare_block(our_metadata_.blocks[i], block)) {
                        FLAC__metadata_iterator_delete(iterator);
                        return die_("metadata block mismatch");
                }
@@ -197,7 +198,7 @@ static FLAC__bool compare_chain_(FLAC__Metadata_Chain *chain, unsigned current_p
                printf("CURRENT_POSITION... ");
                fflush(stdout);
 
-               if(!compare_block_(our_metadata_.blocks[current_position], current_block))
+               if(!mutils__compare_block(our_metadata_.blocks[current_position], current_block))
                        return die_("metadata block mismatch");
        }
 
@@ -253,7 +254,7 @@ static void decoder_metadata_callback_compare_(const FLAC__FileDecoder *decoder,
                dcd->error_occurred = true;
        }
        else {
-               if(!compare_block_(our_metadata_.blocks[mc_our_block_number_], metadata)) {
+               if(!mutils__compare_block(our_metadata_.blocks[mc_our_block_number_], metadata)) {
                        (void)die_("metadata block mismatch");
                        dcd->error_occurred = true;
                }
@@ -376,8 +377,8 @@ static FLAC__bool test_file_(const char *filename, void (*metadata_callback)(con
 
 static FLAC__bool change_stats_(const char *filename, FLAC__bool read_only)
 {
-       if(!file_utils__change_stats(filename, read_only))
-               return die_("during file_utils__change_stats()");
+       if(!grabbag__file_change_stats(filename, read_only))
+               return die_("during grabbag__file_change_stats()");
 
        return true;
 }
@@ -387,7 +388,7 @@ static FLAC__bool remove_file_(const char *filename)
        while(our_metadata_.num_blocks > 0)
                delete_from_our_metadata_(0);
 
-       if(!file_utils__remove_file(filename))
+       if(!grabbag__file_remove_file(filename))
                return die_("removing file");
 
        return true;
@@ -433,6 +434,9 @@ static FLAC__bool test_level_1_()
        FLAC__byte data[1000];
        unsigned our_current_position = 0;
 
+       /* initialize 'data' to avoid Valgrind errors */
+       memset(data, 0, sizeof(data));
+
        printf("\n\n++++++ testing level 1 interface\n");
 
        /************************************************************/
@@ -451,7 +455,7 @@ static FLAC__bool test_level_1_()
        if(0 == (iterator = FLAC__metadata_simple_iterator_new()))
                return die_("FLAC__metadata_simple_iterator_new()");
 
-       if(!FLAC__metadata_simple_iterator_init(iterator, flacfile_, false))
+       if(!FLAC__metadata_simple_iterator_init(iterator, flacfile_, /*read_only=*/false, /*preserve_file_stats=*/false))
                return die_("FLAC__metadata_simple_iterator_init() returned false");
 
        printf("is writable = %u\n", (unsigned)FLAC__metadata_simple_iterator_is_writable(iterator));
@@ -481,6 +485,7 @@ static FLAC__bool test_level_1_()
                return die_("mismatch in min_blocksize");
        if(block->data.stream_info.max_blocksize != 576)
                return die_("mismatch in max_blocksize");
+       FLAC__metadata_object_delete(block);
 
        if(!FLAC__metadata_simple_iterator_next(iterator))
                return die_("forward iterator ended early");
@@ -501,6 +506,7 @@ static FLAC__bool test_level_1_()
        /* check to see if some basic data matches (c.f. generate_file_()) */
        if(block->length != 1234)
                return die_("bad PADDING length");
+       FLAC__metadata_object_delete(block);
 
        if(FLAC__metadata_simple_iterator_next(iterator))
                return die_("forward iterator returned true but should have returned false");
@@ -544,7 +550,7 @@ static FLAC__bool test_level_1_()
        if(0 == (iterator = FLAC__metadata_simple_iterator_new()))
                return die_("FLAC__metadata_simple_iterator_new()");
 
-       if(!FLAC__metadata_simple_iterator_init(iterator, flacfile_, /*preserve_file_stats=*/false))
+       if(!FLAC__metadata_simple_iterator_init(iterator, flacfile_, /*read_only=*/false, /*preserve_file_stats=*/false))
                return die_("FLAC__metadata_simple_iterator_init() returned false");
        our_current_position = 0;
 
@@ -1089,6 +1095,9 @@ static FLAC__bool test_level_2_()
        FLAC__byte data[2000];
        unsigned our_current_position;
 
+       /* initialize 'data' to avoid Valgrind errors */
+       memset(data, 0, sizeof(data));
+
        printf("\n\n++++++ testing level 2 interface\n");
 
        printf("generate read-only file\n");