irungentoo/ProjectTox-Core — pull request #757 by nurupo (2014-02-22 01:56:07+00:00)
Title: Added size functions for names and status messages

There are
```C
int tox_get_status_message(Tox *tox, int32_t friendnumber, uint8_t *buf, uint32_t maxlen);
int tox_get_self_status_message(Tox *tox, uint8_t *buf, uint32_t maxlen);
```
but only one of them has a corresponding `*_size` function
```C
int tox_get_status_message_size(Tox *tox, int32_t friendnumber);
```
which makes people wonder how should they get a size of the `self_status_message`, pass `-1` for `friendnumber`? The answer is that there is no function that would get you `self_status_message_size`.

Also,
```C
uint16_t tox_get_self_name(Tox *tox, uint8_t *name);
int tox_get_name(Tox *tox, int32_t friendnumber, uint8_t *name);
```
don't have any corresponding `*_size` function, instead it's asked to use a big enough buffer, of `MAX_NAME_LENGTH` length.

Something must be done with such API inconsistency.
Since we have exact lengths of name and status message stored, we can easily provide `*_size` functions, it's just a matter of returning already existing variable. If users wish to continue initialize buffers with `MAX_NAME_LENGTH` and like, they can continue doing that -- nothing would break.

-

@irungentoo we return `uint16_t` lengths as an `int`. `int`'s minimum guaranteed max size is 2^15 - 1 = 32767, while `uint16_t`'s, obviously, is 2^16 - 1 = 65535. It's not that name and status message use such big values or we are running Tox on micro-controllers, but that's still worth of mentioning.

-

Also, wait on Travis.