diff options
author | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-20 10:37:18 +0800 |
---|---|---|
committer | ꦌ ꦫꦶ ꦏ꧀ꦦꦿ ꦧ ꦮ ꦑ ꦩ ꦭ꧀ <erik@darapsa.co.id> | 2019-09-20 10:37:18 +0800 |
commit | 33c38800f850bb673bbe1555e007a2e462e682c7 (patch) | |
tree | 1baa4a3d08fc36272acae4f0d555110b3b725c90 | |
parent | 0898723a7387f8e5d3086dd9511d88561ccc2593 (diff) |
Change user ID type to unsigned integer
-rw-r--r-- | rtclient/user.h | 2 | ||||
-rw-r--r-- | user.c | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/rtclient/user.h b/rtclient/user.h index 5c57cb7..54b15bd 100644 --- a/rtclient/user.h +++ b/rtclient/user.h @@ -409,7 +409,7 @@ enum rtclient_timezone { }; struct rtclient_user { - char *id; + unsigned int id; char *name; char *password; char *emailaddress; @@ -74,8 +74,8 @@ static size_t show_callback(void *contents, size_t size, size_t nmemb token = strtok_r(line, ":", &tokensaveptr); if (!strcmp(token, "id")) { token = strtok_r(NULL, ":", &tokensaveptr); - user->id = malloc(strlen(token)); - strcpy(user->id, ++token); + token += 6; + user->id = atoi(token); } else if (!strcmp(token, "Password")) { token = strtok_r(NULL, ":", &tokensaveptr); user->password = malloc(strlen(token)); @@ -184,7 +184,7 @@ static inline void user_init(rtclient_user **userptr) { *userptr = malloc(sizeof(rtclient_user)); rtclient_user *user = *userptr; - user->id = NULL; + user->id = 0; user->name = NULL; user->password = NULL; user->emailaddress = NULL; @@ -227,8 +227,6 @@ void rtclient_user_showname(rtclient_user **userptr, const char *name) void rtclient_user_free(rtclient_user *user) { - if (user->id) - free(user->id); if (user->name) free(user->name); if (user->password) |