1
0
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:
thor
2011-01-08 09:36:16 +00:00
parent c2e8abacc7
commit c971c4c202
2 changed files with 6 additions and 5 deletions

View File

@ -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;
}

View File

@ -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 );