From 33c38800f850bb673bbe1555e007a2e462e682c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=20=EA=A6=AB=EA=A6=B6=20=EA=A6=8F=EA=A7=80?= =?UTF-8?q?=EA=A6=A6=EA=A6=BF=20=EA=A6=A7=20=EA=A6=AE=20=EA=A6=91=20?= =?UTF-8?q?=EA=A6=A9=20=EA=A6=AD=EA=A7=80?= Date: Fri, 20 Sep 2019 10:37:18 +0800 Subject: Change user ID type to unsigned integer --- rtclient/user.h | 2 +- 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; diff --git a/user.c b/user.c index 3e1db94..38c0178 100644 --- a/user.c +++ b/user.c @@ -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) -- cgit v1.2.3