From 1e4b2336a6bb12cf7adbc1718e6455b5f1fd10f0 Mon Sep 17 00:00:00 2001 From: 3Daniel Date: Wed, 27 Jun 2018 23:15:05 +1200 Subject: [PATCH] Updated to address comments --- nx/source/services/acc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nx/source/services/acc.c b/nx/source/services/acc.c index 8db33a65..19c730e4 100644 --- a/nx/source/services/acc.c +++ b/nx/source/services/acc.c @@ -114,17 +114,15 @@ Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_tot Result rc=0; u128 *temp_userIDs; - temp_userIDs = malloc(sizeof(u128) * ACC_USER_LIST_SIZE); + temp_userIDs = malloc(sizeof(u128) * ACC_USER_LIST_SIZE); rc = _accountListAllUsers(temp_userIDs); if (R_SUCCEEDED(rc)) { - size_t total_userIDs = 0; - - for (int i = 0; i < ACC_USER_LIST_SIZE; i++) { - if (temp_userIDs[i]) { - total_userIDs++; - } + size_t total_userIDs; + for (total_userIDs = 0; total_userIDs < ACC_USER_LIST_SIZE; total_userIDs++) { + if (!temp_userIDs[total_userIDs]) + break; } if (max_userIDs > total_userIDs) { @@ -135,9 +133,11 @@ Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_tot userIDs[i] = temp_userIDs[i]; } - *actual_total = total_userIDs; + *actual_total = max_userIDs; } + free(temp_userIDs); + return rc; }