mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-12-06 08:42:39 -08:00
Use HOST_NAME_MAX instead of hardcoding the maximum hostname length
This commit is contained in:
1 parent
d74512bebb
commit
a1d8aef1d6
3 files changed
+12
-8
No files matched your search
+6
-6
@@ -1,13 +1,13 @@
|
||||
#include "hostname.h"
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
std::string hostname()
|
||||
{
|
||||
char buf[256];
|
||||
int code = gethostname(buf, 256);
|
||||
if (code == 0)
|
||||
return std::string(buf);
|
||||
return "unknown";
|
||||
char buf[HOST_NAME_MAX];
|
||||
int code = gethostname(buf, HOST_NAME_MAX);
|
||||
if (code == 0)
|
||||
return buf;
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user