initialize name_length

This commit is contained in:
Jfreegman 2013-09-09 06:41:33 -04:00
parent 0d41d7f9c0
commit 3853a30acf
2 changed files with 5 additions and 3 deletions

View File

@ -346,7 +346,7 @@ static int m_sendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t le
return write_cryptpacket_id(m, friendnumber, PACKET_ID_NICKNAME, name, length);
}
/* Set the name of a friend.
/* Set the name and name_length of a friend.
*
* return 0 if success.
* return -1 if failure.
@ -356,7 +356,9 @@ static int setfriendname(Messenger *m, int friendnumber, uint8_t *name)
if (friend_not_valid(m, friendnumber))
return -1;
memcpy(m->friendlist[friendnumber].name, name, MAX_NAME_LENGTH);
uint16_t len = strlen(name) + 1;
m->friendlist[friendnumber].name_length = len;
memcpy(m->friendlist[friendnumber].name, name, len);
return 0;
}

View File

@ -184,7 +184,7 @@ uint16_t tox_getselfname(void *tox, uint8_t *name, uint16_t nlen)
/* Get name of friendnumber and put it in name.
* name needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
*
* return 0 if success.
* return length of name (with the NULL terminator) if success.
* return -1 if failure.
*/
int tox_getname(void *tox, int friendnumber, uint8_t *name)