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
1434e5a2
Commit
1434e5a2
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/gme,input/curl,...: use static buffers instead of g_strdup_printf()
parent
9acc1e1e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
42 deletions
+37
-42
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+7
-13
GmeDecoderPlugin.cxx
src/decoder/GmeDecoderPlugin.cxx
+13
-9
sidplay_decoder_plugin.cxx
src/decoder/sidplay_decoder_plugin.cxx
+5
-4
CurlInputPlugin.cxx
src/input/CurlInputPlugin.cxx
+7
-9
PlsPlaylistPlugin.cxx
src/playlist/PlsPlaylistPlugin.cxx
+5
-7
No files found.
src/decoder/FfmpegDecoderPlugin.cxx
View file @
1434e5a2
...
...
@@ -31,8 +31,6 @@
#include "util/Domain.hxx"
#include "LogV.hxx"
#include <glib.h>
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
...
...
@@ -84,10 +82,11 @@ mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
cls
=
*
(
const
AVClass
*
const
*
)
ptr
;
if
(
cls
!=
NULL
)
{
char
*
domain
=
g_strconcat
(
ffmpeg_domain
.
GetName
(),
"/"
,
cls
->
item_name
(
ptr
),
NULL
);
char
domain
[
64
];
snprintf
(
domain
,
sizeof
(
domain
),
"%s/%s"
,
ffmpeg_domain
.
GetName
(),
cls
->
item_name
(
ptr
));
const
Domain
d
(
domain
);
LogFormatV
(
d
,
import_ffmpeg_level
(
level
),
fmt
,
vl
);
g_free
(
domain
);
}
}
...
...
@@ -351,12 +350,10 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
Error
error
;
unsigned
char
*
buffer
=
(
unsigned
char
*
)
g_malloc
(
BUFFER_SIZE
)
;
unsigned
char
buffer
[
BUFFER_SIZE
]
;
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
if
(
nbytes
<=
PADDING
||
!
is
->
LockSeek
(
0
,
SEEK_SET
,
error
))
{
g_free
(
buffer
);
return
NULL
;
}
if
(
nbytes
<=
PADDING
||
!
is
->
LockSeek
(
0
,
SEEK_SET
,
error
))
return
nullptr
;
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
beyond the declared buffer limit, which makes valgrind
...
...
@@ -369,10 +366,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
avpd
.
buf_size
=
nbytes
;
avpd
.
filename
=
is
->
uri
.
c_str
();
AVInputFormat
*
format
=
av_probe_input_format
(
&
avpd
,
true
);
g_free
(
buffer
);
return
format
;
return
av_probe_input_format
(
&
avpd
,
true
);
}
static
void
...
...
src/decoder/GmeDecoderPlugin.cxx
View file @
1434e5a2
...
...
@@ -53,10 +53,12 @@ get_container_name(const char *path_fs)
{
const
char
*
subtune_suffix
=
uri_get_suffix
(
path_fs
);
char
*
path_container
=
g_strdup
(
path_fs
);
char
*
pat
=
g_strconcat
(
"*/"
SUBTUNE_PREFIX
"???."
,
subtune_suffix
,
nullptr
);
char
pat
[
64
];
snprintf
(
pat
,
sizeof
(
pat
),
"%s%s"
,
"*/"
SUBTUNE_PREFIX
"???."
,
subtune_suffix
);
GPatternSpec
*
path_with_subtune
=
g_pattern_spec_new
(
pat
);
g_free
(
pat
);
if
(
!
g_pattern_match
(
path_with_subtune
,
strlen
(
path_container
),
path_container
,
nullptr
))
{
g_pattern_spec_free
(
path_with_subtune
);
...
...
@@ -79,10 +81,12 @@ static int
get_song_num
(
const
char
*
path_fs
)
{
const
char
*
subtune_suffix
=
uri_get_suffix
(
path_fs
);
char
*
pat
=
g_strconcat
(
"*/"
SUBTUNE_PREFIX
"???."
,
subtune_suffix
,
nullptr
);
char
pat
[
64
];
snprintf
(
pat
,
sizeof
(
pat
),
"%s%s"
,
"*/"
SUBTUNE_PREFIX
"???."
,
subtune_suffix
);
GPatternSpec
*
path_with_subtune
=
g_pattern_spec_new
(
pat
);
g_free
(
pat
);
if
(
g_pattern_match
(
path_with_subtune
,
strlen
(
path_fs
),
path_fs
,
nullptr
))
{
...
...
@@ -235,13 +239,13 @@ gme_scan_file(const char *path_fs,
if
(
ti
->
song
!=
nullptr
)
{
if
(
gme_track_count
(
emu
)
>
1
)
{
/* start numbering subtunes from 1 */
char
*
tag_title
=
g_strdup_printf
(
"%s (%d/%d)"
,
char
tag_title
[
1024
];
snprintf
(
tag_title
,
sizeof
(
tag_title
),
"%s (%d/%d)"
,
ti
->
song
,
song_num
+
1
,
gme_track_count
(
emu
));
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TITLE
,
tag_title
);
g_free
(
tag_title
);
}
else
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TITLE
,
ti
->
song
);
...
...
src/decoder/sidplay_decoder_plugin.cxx
View file @
1434e5a2
...
...
@@ -359,11 +359,12 @@ sidplay_scan_file(const char *path_fs,
title
=
""
;
if
(
info
.
songs
>
1
)
{
char
*
tag_title
=
g_strdup_printf
(
"%s (%d/%d)"
,
char
tag_title
[
1024
];
snprintf
(
tag_title
,
sizeof
(
tag_title
),
"%s (%d/%d)"
,
title
,
song_num
,
info
.
songs
);
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TITLE
,
tag_title
);
g_free
(
tag_title
);
}
else
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TITLE
,
title
);
...
...
@@ -373,9 +374,9 @@ sidplay_scan_file(const char *path_fs,
info
.
infoString
[
1
]);
/* track */
char
*
track
=
g_strdup_printf
(
"%d"
,
song_num
);
char
track
[
16
];
sprintf
(
track
,
"%d"
,
song_num
);
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
TAG_TRACK
,
track
);
g_free
(
track
);
/* time */
int
song_len
=
get_song_length
(
path_fs
);
...
...
src/input/CurlInputPlugin.cxx
View file @
1434e5a2
...
...
@@ -134,7 +134,7 @@ struct input_curl {
/* some buffers which were passed to libcurl, which we have
too free */
char
*
range
;
char
range
[
32
]
;
struct
curl_slist
*
request_headers
;
/** the curl handles */
...
...
@@ -168,7 +168,7 @@ struct input_curl {
input_curl
(
const
char
*
url
,
Mutex
&
mutex
,
Cond
&
cond
)
:
base
(
input_plugin_curl
,
url
,
mutex
,
cond
),
r
ange
(
nullptr
),
r
equest_headers
(
nullptr
),
request_headers
(
nullptr
),
paused
(
false
),
meta_name
(
nullptr
),
tag
(
nullptr
)
{}
...
...
@@ -383,9 +383,6 @@ input_curl_easy_free(struct input_curl *c)
curl_slist_free_all
(
c
->
request_headers
);
c
->
request_headers
=
NULL
;
g_free
(
c
->
range
);
c
->
range
=
NULL
;
}
/**
...
...
@@ -958,10 +955,11 @@ input_curl_easy_init(struct input_curl *c, Error &error)
curl_easy_setopt
(
c
->
easy
,
CURLOPT_PROXYPORT
,
(
long
)
proxy_port
);
if
(
proxy_user
!=
NULL
&&
proxy_password
!=
NULL
)
{
char
*
proxy_auth_str
=
g_strconcat
(
proxy_user
,
":"
,
proxy_password
,
NULL
);
char
proxy_auth_str
[
1024
];
snprintf
(
proxy_auth_str
,
sizeof
(
proxy_auth_str
),
"%s:%s"
,
proxy_user
,
proxy_password
);
curl_easy_setopt
(
c
->
easy
,
CURLOPT_PROXYUSERPWD
,
proxy_auth_str
);
g_free
(
proxy_auth_str
);
}
code
=
curl_easy_setopt
(
c
->
easy
,
CURLOPT_URL
,
c
->
base
.
uri
.
c_str
());
...
...
@@ -1062,7 +1060,7 @@ input_curl_seek(struct input_stream *is, InputPlugin::offset_type offset,
/* send the "Range" header */
if
(
is
->
offset
>
0
)
{
c
->
range
=
g_strdup_printf
(
"%lld-"
,
(
long
long
)
is
->
offset
);
sprintf
(
c
->
range
,
"%lld-"
,
(
long
long
)
is
->
offset
);
curl_easy_setopt
(
c
->
easy
,
CURLOPT_RANGE
,
c
->
range
);
}
...
...
src/playlist/PlsPlaylistPlugin.cxx
View file @
1434e5a2
...
...
@@ -37,7 +37,6 @@ static constexpr Domain pls_domain("pls");
static
void
pls_parser
(
GKeyFile
*
keyfile
,
std
::
forward_list
<
SongPointer
>
&
songs
)
{
gchar
*
key
;
gchar
*
value
;
int
length
;
GError
*
error
=
NULL
;
...
...
@@ -60,7 +59,9 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
while
(
num_entries
>
0
)
{
Song
*
song
;
key
=
g_strdup_printf
(
"File%i"
,
num_entries
);
char
key
[
64
];
sprintf
(
key
,
"File%u"
,
num_entries
);
value
=
g_key_file_get_string
(
keyfile
,
"playlist"
,
key
,
&
error
);
if
(
error
)
{
...
...
@@ -70,15 +71,13 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
g_free
(
key
);
return
;
}
g_free
(
key
);
song
=
Song
::
NewRemote
(
value
);
g_free
(
value
);
key
=
g_strdup_printf
(
"Title%i
"
,
num_entries
);
sprintf
(
key
,
"Title%u
"
,
num_entries
);
value
=
g_key_file_get_string
(
keyfile
,
"playlist"
,
key
,
&
error
);
g_free
(
key
);
if
(
error
==
NULL
&&
value
){
if
(
song
->
tag
==
NULL
)
song
->
tag
=
new
Tag
();
...
...
@@ -89,10 +88,9 @@ pls_parser(GKeyFile *keyfile, std::forward_list<SongPointer> &songs)
error
=
NULL
;
g_free
(
value
);
key
=
g_strdup_printf
(
"Length%i
"
,
num_entries
);
sprintf
(
key
,
"Length%u
"
,
num_entries
);
length
=
g_key_file_get_integer
(
keyfile
,
"playlist"
,
key
,
&
error
);
g_free
(
key
);
if
(
error
==
NULL
&&
length
>
0
){
if
(
song
->
tag
==
NULL
)
song
->
tag
=
new
Tag
();
...
...
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