Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c157711e
Commit
c157711e
authored
Dec 31, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/bz2: allocate buffer statically
Reduce the number of malloc()/free() calls.
parent
26327945
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
bz2_archive_plugin.c
src/archive/bz2_archive_plugin.c
+3
-7
No files found.
src/archive/bz2_archive_plugin.c
View file @
c157711e
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment