diff options
author | Pierre Ossman <ossman@cendio.se> | 2024-04-02 16:13:23 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-06-24 13:42:54 +0200 |
commit | 139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901 (patch) | |
tree | 8d06ede9e14516516a44c5ed710058003088eec2 /common/rfb/Hostname.h | |
parent | 45198e5235f4b724277665b242cf855a0ff4518b (diff) | |
download | tigervnc-139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901.tar.gz tigervnc-139f0e8a4b81fe3dcd9476ec5ee16ea5e74af901.zip |
Use nullptr in all C++ code
It's more readable than 0, and a bit safer than NULL, so let's try to
follow modern norms.
Diffstat (limited to 'common/rfb/Hostname.h')
-rw-r--r-- | common/rfb/Hostname.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/common/rfb/Hostname.h b/common/rfb/Hostname.h index 1971e343..a09cca3f 100644 --- a/common/rfb/Hostname.h +++ b/common/rfb/Hostname.h @@ -29,7 +29,7 @@ namespace rfb { static bool isAllSpace(const char *string) { - if (string == NULL) + if (string == nullptr) return false; while(*string != '\0') { if (! isspace(*string)) @@ -46,7 +46,7 @@ namespace rfb { const char* hostEnd; const char* portStart; - if (hi == NULL) + if (hi == nullptr) throw rdr::Exception("NULL host specified"); // Trim leading whitespace @@ -59,19 +59,19 @@ namespace rfb { if (hi[0] == '[') { hostStart = &hi[1]; hostEnd = strchr(hostStart, ']'); - if (hostEnd == NULL) + if (hostEnd == nullptr) throw rdr::Exception("unmatched [ in host"); portStart = hostEnd + 1; if (isAllSpace(portStart)) - portStart = NULL; + portStart = nullptr; } else { hostStart = &hi[0]; hostEnd = strrchr(hostStart, ':'); - if (hostEnd == NULL) { + if (hostEnd == nullptr) { hostEnd = hostStart + strlen(hostStart); - portStart = NULL; + portStart = nullptr; } else { if ((hostEnd > hostStart) && (hostEnd[-1] == ':')) hostEnd--; @@ -79,7 +79,7 @@ namespace rfb { if (portStart != hostEnd) { // We found more : in the host. This is probably an IPv6 address hostEnd = hostStart + strlen(hostStart); - portStart = NULL; + portStart = nullptr; } } } @@ -93,7 +93,7 @@ namespace rfb { else *host = std::string(hostStart, hostEnd - hostStart); - if (portStart == NULL) + if (portStart == nullptr) *port = basePort; else { char* end; |