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
0c53e8c2
Commit
0c53e8c2
authored
Dec 04, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system/Resolver: use std::string to allocate internal buffer
No GLib memory allocation.
parent
e1901e97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
+11
-13
Resolver.cxx
src/system/Resolver.cxx
+11
-13
No files found.
src/system/Resolver.cxx
View file @
0c53e8c2
...
...
@@ -22,8 +22,6 @@
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <glib.h>
#ifndef WIN32
#include <sys/socket.h>
#include <netdb.h>
...
...
@@ -107,19 +105,19 @@ resolve_host_port(const char *host_port, unsigned default_port,
int
flags
,
int
socktype
,
Error
&
error
)
{
char
*
p
=
g_strdu
p
(
host_port
);
const
char
*
host
=
p
,
*
port
=
NULL
;
std
::
string
p
(
host_port
);
const
char
*
host
=
p
.
c_str
(),
*
port
=
nullptr
;
if
(
host_port
[
0
]
==
'['
)
{
/* IPv6 needs enclosing square braces, to
differentiate between IP colons and the port
separator */
char
*
q
=
strchr
(
p
+
1
,
']'
);
if
(
q
!=
NULL
&&
q
[
1
]
==
':'
&&
q
[
2
]
!=
0
)
{
*
q
=
0
;
size_t
q
=
p
.
find
(
']'
,
1
);
if
(
q
!=
p
.
npos
&&
p
[
q
+
1
]
==
':'
&&
p
[
q
+
2
]
!=
0
)
{
p
[
q
]
=
0
;
port
=
host
+
q
+
2
;
++
host
;
port
=
q
+
2
;
}
}
...
...
@@ -127,10 +125,11 @@ resolve_host_port(const char *host_port, unsigned default_port,
/* port is after the colon, but only if it's the only
colon (don't split IPv6 addresses) */
char
*
q
=
strchr
(
p
,
':'
);
if
(
q
!=
NULL
&&
q
[
1
]
!=
0
&&
strchr
(
q
+
1
,
':'
)
==
NULL
)
{
*
q
=
0
;
port
=
q
+
1
;
auto
q
=
p
.
find
(
':'
);
if
(
q
!=
p
.
npos
&&
p
[
q
+
1
]
!=
0
&&
p
.
find
(
':'
,
q
+
1
)
==
p
.
npos
)
{
p
[
q
]
=
0
;
port
=
host
+
q
+
1
;
}
}
...
...
@@ -151,7 +150,6 @@ resolve_host_port(const char *host_port, unsigned default_port,
struct
addrinfo
*
ai
;
int
ret
=
getaddrinfo
(
host
,
port
,
&
hints
,
&
ai
);
g_free
(
p
);
if
(
ret
!=
0
)
{
error
.
Format
(
resolver_domain
,
ret
,
"Failed to look up '%s': %s"
,
...
...
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