ipc_helpers: Make PushStaticBuffer take std::vector by value
Allows interfaces to move the vector into the calls, avoiding any reallocations. Many existing call sites already std::move into the parameter, expecting a move to occur. Only a few remain where this wasn't already being done, which we can convert over.
This commit is contained in:
@ -29,52 +29,52 @@ void Module::Interface::GetMyPresence(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
rb.PushStaticBuffer(std::move(buffer), 0);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
}
|
||||
|
||||
void Module::Interface::GetFriendKeyList(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x11, 2, 0);
|
||||
u32 unknown = rp.Pop<u32>();
|
||||
u32 frd_count = rp.Pop<u32>();
|
||||
const u32 unknown = rp.Pop<u32>();
|
||||
const u32 frd_count = rp.Pop<u32>();
|
||||
|
||||
std::vector<u8> buffer(sizeof(FriendKey) * frd_count, 0);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.Push<u32>(0); // 0 friends
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
rb.PushStaticBuffer(std::move(buffer), 0);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, unknown={}, frd_count={}", unknown, frd_count);
|
||||
}
|
||||
|
||||
void Module::Interface::GetFriendProfile(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x15, 1, 2);
|
||||
u32 count = rp.Pop<u32>();
|
||||
std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
const u32 count = rp.Pop<u32>();
|
||||
const std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
ASSERT(frd_keys.size() == count * sizeof(FriendKey));
|
||||
|
||||
std::vector<u8> buffer(sizeof(Profile) * count, 0);
|
||||
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
rb.PushStaticBuffer(std::move(buffer), 0);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
|
||||
}
|
||||
|
||||
void Module::Interface::GetFriendAttributeFlags(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp(ctx, 0x17, 1, 2);
|
||||
u32 count = rp.Pop<u32>();
|
||||
std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
const u32 count = rp.Pop<u32>();
|
||||
const std::vector<u8> frd_keys = rp.PopStaticBuffer();
|
||||
ASSERT(frd_keys.size() == count * sizeof(FriendKey));
|
||||
|
||||
// TODO:(mailwl) figure out AttributeFlag size and zero all buffer. Assume 1 byte
|
||||
std::vector<u8> buffer(1 * count, 0);
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(buffer, 0);
|
||||
rb.PushStaticBuffer(std::move(buffer), 0);
|
||||
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called, count={}", count);
|
||||
}
|
||||
@ -111,7 +111,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx
|
||||
|
||||
IPC::RequestParser rp(ctx, 0x1C, 1, 2);
|
||||
const u32 friend_code_count = rp.Pop<u32>();
|
||||
std::vector<u8> scrambled_friend_codes = rp.PopStaticBuffer();
|
||||
const std::vector<u8> scrambled_friend_codes = rp.PopStaticBuffer();
|
||||
ASSERT_MSG(scrambled_friend_codes.size() == (friend_code_count * scrambled_friend_code_size),
|
||||
"Wrong input buffer size");
|
||||
|
||||
@ -133,7 +133,7 @@ void Module::Interface::UnscrambleLocalFriendCode(Kernel::HLERequestContext& ctx
|
||||
LOG_WARNING(Service_FRD, "(STUBBED) called");
|
||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushStaticBuffer(unscrambled_friend_codes, 0);
|
||||
rb.PushStaticBuffer(std::move(unscrambled_friend_codes), 0);
|
||||
}
|
||||
|
||||
void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) {
|
||||
|
Reference in New Issue
Block a user