diff -c -r flac-1.1.2/include/FLAC++/encoder.h flac-1.1.2-mod/include/FLAC++/encoder.h
*** flac-1.1.2/include/FLAC++/encoder.h	2005-01-27 03:27:40.000000000 +0800
--- flac-1.1.2-mod/include/FLAC++/encoder.h	2006-08-22 09:27:54.000000000 +0800
***************
*** 324,330 ****
--- 324,337 ----
  			bool set_max_residual_partition_order(unsigned value);
  			bool set_rice_parameter_search_dist(unsigned value);
  			bool set_total_samples_estimate(FLAC__uint64 value);
+ 			/** Note that if metadata is dynamically allocated,
+ 			 * the objects pointed to must exist until init() is called.
+ 			 */
  			bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
+ 			/** Converts the given metadata objects to suit the encoder.
+ 			 * Note that if metadata is dynamically allocated,
+ 			 * the objects pointed to must exist until init() is called.
+ 			 */
  			bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks);
  			bool set_filename(const char *value);
  
***************
*** 365,370 ****
--- 372,378 ----
  			friend State;
  #endif
  			::FLAC__FileEncoder *encoder_;
+ 			::FLAC__StreamMetadata **metadata_;
  		private:
  			static void progress_callback_(const ::FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
  
diff -c -r flac-1.1.2/src/libFLAC++/file_encoder.cpp flac-1.1.2-mod/src/libFLAC++/file_encoder.cpp
*** flac-1.1.2/src/libFLAC++/file_encoder.cpp	2005-01-27 03:29:08.000000000 +0800
--- flac-1.1.2-mod/src/libFLAC++/file_encoder.cpp	2006-08-22 09:27:35.000000000 +0800
***************
*** 41,47 ****
  	namespace Encoder {
  
  		File::File():
! 		encoder_(::FLAC__file_encoder_new())
  		{ }
  
  		File::~File()
--- 41,48 ----
  	namespace Encoder {
  
  		File::File():
! 		encoder_(::FLAC__file_encoder_new()),
! 		metadata_(0)
  		{ }
  
  		File::~File()
***************
*** 50,55 ****
--- 51,59 ----
  				::FLAC__file_encoder_finish(encoder_);
  				::FLAC__file_encoder_delete(encoder_);
  			}
+ 			if(0 != metadata_) {
+ 				delete [] metadata_;
+ 			}
  		}
  
  		bool File::is_valid() const
***************
*** 168,193 ****
  		bool File::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
  		{
  			FLAC__ASSERT(is_valid());
- #if (defined _MSC_VER) || (defined __SUNPRO_CC)
- 			// MSVC++ can't handle:
- 			// ::FLAC__StreamMetadata *m[num_blocks];
- 			// so we do this ugly workaround
  			::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
- #else
- 			::FLAC__StreamMetadata *m[num_blocks];
- #endif
  			for(unsigned i = 0; i < num_blocks; i++) {
  				// we can get away with this since we know the encoder will only correct the is_last flags
! 				m[i] = const_cast< ::FLAC__StreamMetadata*>((::FLAC__StreamMetadata*)metadata[i]);
  			}
! #if (defined _MSC_VER) || (defined __SUNPRO_CC)
! 			// complete the hack
! 			const bool ok = (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
! 			delete [] m;
! 			return ok;
! #else
  			return (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
- #endif
  		}
  
  		bool File::set_filename(const char *value)
--- 172,188 ----
  		bool File::set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks)
  		{
  			FLAC__ASSERT(is_valid());
  			::FLAC__StreamMetadata **m = new ::FLAC__StreamMetadata*[num_blocks];
  			for(unsigned i = 0; i < num_blocks; i++) {
  				// we can get away with this since we know the encoder will only correct the is_last flags
! 				m[i] = const_cast< ::FLAC__StreamMetadata*>(static_cast<const ::FLAC__StreamMetadata*>(*metadata[i]));
! 			}
! 			if(0 != metadata_) {
! 				delete [] metadata_;
  			}
! 			// postpone deletion until after init
! 			metadata_ = m;
  			return (bool)::FLAC__file_encoder_set_metadata(encoder_, m, num_blocks);
  		}
  
  		bool File::set_filename(const char *value)
