Correct the max hostname length constant.

256 bytes including NUL byte is confusing and makes for really annoying
bindings to other languages that don't account for NUL bytes in their
string length. We pass C strings, not byte arrays, for hostnames, so 255
makes more sense here.
This commit is contained in:
iphydf 2018-07-18 00:19:24 +00:00
parent 13aa33a0f8
commit 392eef7900
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 6 additions and 6 deletions

View File

@ -318,12 +318,12 @@ const MAX_FILENAME_LENGTH = 255;
/**
* Maximum length of a hostname, e.g. proxy or bootstrap node names.
*
* This length includes the NUL byte. Hostnames are NUL-terminated C strings, so
* they are 255 characters plus one NUL byte.
* This length does not include the NUL byte. Hostnames are NUL-terminated C
* strings, so they are 255 characters plus one NUL byte.
*
* @deprecated The macro will be removed in 0.3.0. Use the function instead.
*/
const MAX_HOSTNAME_LENGTH = 256;
const MAX_HOSTNAME_LENGTH = 255;
/*******************************************************************************

View File

@ -345,12 +345,12 @@ uint32_t tox_max_filename_length(void);
/**
* Maximum length of a hostname, e.g. proxy or bootstrap node names.
*
* This length includes the NUL byte. Hostnames are NUL-terminated C strings, so
* they are 255 characters plus one NUL byte.
* This length does not include the NUL byte. Hostnames are NUL-terminated C
* strings, so they are 255 characters plus one NUL byte.
*
* @deprecated The macro will be removed in 0.3.0. Use the function instead.
*/
#define TOX_MAX_HOSTNAME_LENGTH 256
#define TOX_MAX_HOSTNAME_LENGTH 255
uint32_t tox_max_hostname_length(void);