added output_buffer_free()

To do proper cleanup before exiting, we have to provide a destructor
for OutputBuffer.  One day, valgrind will not complain about memory
leaks!

git-svn-id: https://svn.musicpd.org/mpd/trunk@7315 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Max Kellermann 2008-04-12 04:18:38 +00:00 committed by Eric Wong
parent b688134586
commit f2cdac6ee7
3 changed files with 9 additions and 0 deletions

View File

@ -36,6 +36,12 @@ void initOutputBuffer(OutputBuffer * cb, unsigned int size)
cb->currentChunk = -1; cb->currentChunk = -1;
} }
void output_buffer_free(OutputBuffer * cb)
{
assert(cb->chunks != NULL);
free(cb->chunks);
}
void clearOutputBuffer(OutputBuffer * cb) void clearOutputBuffer(OutputBuffer * cb)
{ {
cb->end = cb->begin; cb->end = cb->begin;

View File

@ -62,6 +62,8 @@ typedef struct _OutputBuffer {
void initOutputBuffer(OutputBuffer * cb, unsigned int size); void initOutputBuffer(OutputBuffer * cb, unsigned int size);
void output_buffer_free(OutputBuffer * cb);
void clearOutputBuffer(OutputBuffer * cb); void clearOutputBuffer(OutputBuffer * cb);
void flushOutputBuffer(OutputBuffer * cb); void flushOutputBuffer(OutputBuffer * cb);

View File

@ -116,5 +116,6 @@ void freePlayerData(void)
* access playerData_pd and we need to keep it available for them */ * access playerData_pd and we need to keep it available for them */
waitpid(-1, NULL, 0); waitpid(-1, NULL, 0);
output_buffer_free(&playerData_pd.buffer);
free(playerData_pd.audioDeviceStates); free(playerData_pd.audioDeviceStates);
} }