mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Nuke a sprintf.
This commit is contained in:
parent
693d51859e
commit
2edac1a438
1 changed files with 6 additions and 4 deletions
|
@ -248,7 +248,7 @@ NET_CompareAdr (netadr_t a, netadr_t b)
|
||||||
const char *
|
const char *
|
||||||
NET_AdrToString (netadr_t a)
|
NET_AdrToString (netadr_t a)
|
||||||
{
|
{
|
||||||
static char s[64];
|
static dstring_t *s;
|
||||||
char base[64];
|
char base[64];
|
||||||
AF_address_t ss;
|
AF_address_t ss;
|
||||||
|
|
||||||
|
@ -273,13 +273,15 @@ NET_AdrToString (netadr_t a)
|
||||||
if (getnameinfo (&ss.sa, SS_LEN(&ss.ss), base, sizeof (base),
|
if (getnameinfo (&ss.sa, SS_LEN(&ss.ss), base, sizeof (base),
|
||||||
NULL, 0, NI_NUMERICHOST)) strcpy (base, "<invalid>");
|
NULL, 0, NI_NUMERICHOST)) strcpy (base, "<invalid>");
|
||||||
|
|
||||||
|
if (!s)
|
||||||
|
s = dstring_new ();
|
||||||
if (ss.ss.ss_family == AF_INET6) {
|
if (ss.ss.ss_family == AF_INET6) {
|
||||||
sprintf (s, "[%s]:%d", base, ntohs (a.port));
|
dsprintf (s, "[%s]:%d", base, ntohs (a.port));
|
||||||
} else {
|
} else {
|
||||||
sprintf (s, "%s:%d", base, ntohs (a.port));
|
dsprintf (s, "%s:%d", base, ntohs (a.port));
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
Loading…
Reference in a new issue