mirror of
http://mpg123.de/trunk/.git
synced 2025-07-28 15:02:00 +03:00
Fix a memory leak each. Examples should'n have those... even if it is just on death because of error.
git-svn-id: svn://scm.orgis.org/mpg123/trunk@2828 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
@ -168,6 +168,7 @@ int main(int argc, char **argv)
|
||||
out = fopen(argv[2], "wb");
|
||||
if(out == NULL)
|
||||
{
|
||||
fclose(in);
|
||||
fprintf(stderr,"Unable to open output file %s\n", argv[2]);
|
||||
return -1;
|
||||
}
|
||||
|
@ -67,11 +67,6 @@ int main(int argc, char *argv[])
|
||||
mpg123_format_none(mh);
|
||||
mpg123_format(mh, rate, channels, encoding);
|
||||
|
||||
/* Buffer could be almost any size here, mpg123_outblock() is just some recommendation.
|
||||
Important, especially for sndfile writing, is that the size is a multiple of sample size. */
|
||||
buffer_size = mpg123_outblock( mh );
|
||||
buffer = malloc( buffer_size );
|
||||
|
||||
bzero(&sfinfo, sizeof(sfinfo) );
|
||||
sfinfo.samplerate = rate;
|
||||
sfinfo.channels = channels;
|
||||
@ -81,6 +76,11 @@ int main(int argc, char *argv[])
|
||||
sndfile = sf_open(argv[2], SFM_WRITE, &sfinfo);
|
||||
if(sndfile == NULL){ fprintf(stderr, "Cannot open output file!\n"); cleanup(mh); return -2; }
|
||||
|
||||
/* Buffer could be almost any size here, mpg123_outblock() is just some recommendation.
|
||||
Important, especially for sndfile writing, is that the size is a multiple of sample size. */
|
||||
buffer_size = mpg123_outblock( mh );
|
||||
buffer = malloc( buffer_size );
|
||||
|
||||
do
|
||||
{
|
||||
err = mpg123_read( mh, buffer, buffer_size, &done );
|
||||
|
Reference in New Issue
Block a user