diff options
author | Max Kellermann <max@duempel.org> | 2010-02-14 20:36:31 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-02-17 07:22:44 +0100 |
commit | 5e0117b4441f257fcb1aab48b42a787567ebcbe6 (patch) | |
tree | 7233b273814def640145276f1a46d45b8cf274e4 /src/decoder/flac_metadata.c | |
parent | c05e6a1275621421eb0a7c3112b0401fa458841e (diff) | |
download | mpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.tar.gz mpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.tar.xz mpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.zip |
replay_gain_info: allocate the struct statically
Don't allocate each replay_gain_info object on the heap. Those
objects who held a pointer now store a full replay_gain_info object.
This reduces the number of allocations and heap fragmentation.
Diffstat (limited to 'src/decoder/flac_metadata.c')
-rw-r--r-- | src/decoder/flac_metadata.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c index 2ee1d8234..926cd3af7 100644 --- a/src/decoder/flac_metadata.c +++ b/src/decoder/flac_metadata.c @@ -56,13 +56,13 @@ flac_find_float_comment(const FLAC__StreamMetadata *block, return true; } -struct replay_gain_info * -flac_parse_replay_gain(const FLAC__StreamMetadata *block) +bool +flac_parse_replay_gain(struct replay_gain_info *rgi, + const FLAC__StreamMetadata *block) { - struct replay_gain_info *rgi; bool found = false; - rgi = replay_gain_info_new(); + replay_gain_info_init(rgi); if (flac_find_float_comment(block, "replaygain_album_gain", &rgi->tuples[REPLAY_GAIN_ALBUM].gain)) @@ -77,12 +77,7 @@ flac_parse_replay_gain(const FLAC__StreamMetadata *block) &rgi->tuples[REPLAY_GAIN_TRACK].peak)) found = true; - if (!found) { - replay_gain_info_free(rgi); - rgi = NULL; - } - - return rgi; + return found; } /** |