aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-31 11:01:58 +0100
committerMax Kellermann <max@duempel.org>2009-12-31 16:26:14 +0100
commitc157711eaf7cbe7052f55ba23d8d5ff30507caa3 (patch)
tree2cbe28814032ee7f8b3b25904e14689be3956c70
parent2632794578b5abc14b16c5f67acf1da53fe76b46 (diff)
downloadmpd-c157711eaf7cbe7052f55ba23d8d5ff30507caa3.tar.gz
mpd-c157711eaf7cbe7052f55ba23d8d5ff30507caa3.tar.xz
mpd-c157711eaf7cbe7052f55ba23d8d5ff30507caa3.zip
archive/bz2: allocate buffer statically
Reduce the number of malloc()/free() calls.
Diffstat (limited to '')
-rw-r--r--src/archive/bz2_archive_plugin.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/archive/bz2_archive_plugin.c b/src/archive/bz2_archive_plugin.c
index 2469a5bd6..7e0711676 100644
--- a/src/archive/bz2_archive_plugin.c
+++ b/src/archive/bz2_archive_plugin.c
@@ -37,8 +37,6 @@
#define BZ2_bzDecompress bzDecompress
#endif
-#define BZ_BUFSIZE 5000
-
struct bz2_archive_file {
struct archive_file base;
@@ -53,7 +51,8 @@ struct bz2_input_stream {
bool eof;
bz_stream bzstream;
- char *buffer;
+
+ char buffer[5000];
};
static const struct input_plugin bz2_inputplugin;
@@ -75,13 +74,11 @@ bz2_alloc(struct bz2_input_stream *data, GError **error_r)
data->bzstream.bzfree = NULL;
data->bzstream.opaque = NULL;
- data->buffer = g_malloc(BZ_BUFSIZE);
data->bzstream.next_in = (void *) data->buffer;
data->bzstream.avail_in = 0;
ret = BZ2_bzDecompressInit(&data->bzstream, 0, 0);
if (ret != BZ_OK) {
- g_free(data->buffer);
g_free(data);
g_set_error(error_r, bz2_quark(), ret,
@@ -96,7 +93,6 @@ static void
bz2_destroy(struct bz2_input_stream *data)
{
BZ2_bzDecompressEnd(&data->bzstream);
- g_free(data->buffer);
}
/* archive open && listing routine */
@@ -210,7 +206,7 @@ bz2_fillbuffer(struct bz2_input_stream *bis, GError **error_r)
return true;
count = input_stream_read(&bis->archive->istream,
- bis->buffer, BZ_BUFSIZE,
+ bis->buffer, sizeof(bis->buffer),
error_r);
if (count == 0)
return false;