More corrections to accountListAllUsers

This commit is contained in:
3Daniel 2018-06-28 21:29:24 +12:00
parent 1e4b2336a6
commit 01ed16ea5f
2 changed files with 6 additions and 10 deletions

View File

@ -39,10 +39,10 @@ Service* accountGetService(void);
Result accountGetUserCount(s32* user_count);
/**
* @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE
* @param userIDs Pointer to array of user IDs
* @param max_userIDs Maximum number of user IDs to return
* @param actual_total The actual total number of user IDs found
* @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE.
* @param userIDs Pointer to array of user IDs.
* @param max_userIDs Maximum number of user IDs to return.
* @param actual_total The actual total number of user IDs found.
*/
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total);

View File

@ -112,7 +112,6 @@ static Result _accountListAllUsers(u128* userIDs)
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total)
{
Result rc=0;
u128 *temp_userIDs;
temp_userIDs = malloc(sizeof(u128) * ACC_USER_LIST_SIZE);
@ -126,13 +125,10 @@ Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_tot
}
if (max_userIDs > total_userIDs) {
max_userIDs = total_userIDs;
}
for (int i = 0; i < max_userIDs; i++) {
userIDs[i] = temp_userIDs[i];
memcpy(&max_userIDs, &total_userIDs, sizeof(size_t));
}
memcpy(userIDs, temp_userIDs, sizeof(u128) * max_userIDs);
*actual_total = max_userIDs;
}