Clans: make instance a shared_ptr

This commit is contained in:
zeph 2025-12-08 03:49:56 +01:00
parent 04da801145
commit a9b124f9c6
3 changed files with 15 additions and 14 deletions

View File

@ -5,6 +5,7 @@
#include "Emu/NP/clans_client.h"
#include "sceNp.h"
#include <memory>
#include "sceNpClans.h"
@ -97,7 +98,7 @@ error_code sceNpClansInit(vm::cptr<SceNpCommunicationId> commId, vm::cptr<SceNpC
}
// Allocate space for a client somewhere
clan::clans_client* client = new clan::clans_client();
std::shared_ptr<clan::clans_client> client = std::make_shared<clan::clans_client>();
clans_manager.client = client;
clans_manager.is_initialized = true;
@ -113,7 +114,7 @@ error_code sceNpClansTerm()
return SCE_NP_CLANS_ERROR_NOT_INITIALIZED;
}
delete clans_manager.client;
clans_manager.client.reset();
clans_manager.is_initialized = false;
return CELL_OK;

View File

@ -350,8 +350,8 @@ namespace clan
.role = static_cast<SceNpClansMemberRole>(role_int),
.status = static_cast<SceNpClansMemberStatus>(status_int)};
strcpy_trunc(entry.info.name, name_str.c_str());
strcpy_trunc(entry.info.tag, tag_str.c_str());
strcpy_trunc(entry.info.name, name_str);
strcpy_trunc(entry.info.tag, tag_str);
clanList[i] = entry;
i++;
@ -396,9 +396,9 @@ namespace clan
.description = "",
}};
strcpy_trunc(clanInfo->info.name, name_str.c_str());
strcpy_trunc(clanInfo->info.tag, tag_str.c_str());
strcpy_trunc(clanInfo->updatable.description, description_str.c_str());
strcpy_trunc(clanInfo->info.name, name_str);
strcpy_trunc(clanInfo->info.tag, tag_str);
strcpy_trunc(clanInfo->updatable.description, description_str);
return SCE_NP_CLANS_SUCCESS;
}
@ -453,7 +453,7 @@ namespace clan
std::string description_str = description.text().as_string();
char description_char[256] = {0};
strcpy_trunc(description_char, description_str.c_str());
strcpy_trunc(description_char, description_str);
*memInfo = SceNpClansMemberEntry
{
@ -523,7 +523,7 @@ namespace clan
std::string description_str = info.child("description").text().as_string();
char description_char[256] = {0};
strcpy_trunc(description_char, description_str.c_str());
strcpy_trunc(description_char, description_str);
SceNpClansMemberEntry entry = SceNpClansMemberEntry
{
@ -689,8 +689,8 @@ namespace clan
.reserved = {0, 0},
};
strcpy_trunc(entry.name, name_str.c_str());
strcpy_trunc(entry.tag, tag_str.c_str());
strcpy_trunc(entry.name, name_str);
strcpy_trunc(entry.tag, tag_str);
clanList[i] = entry;
i++;
@ -973,8 +973,8 @@ namespace clan
.postedBy = clanId,
};
strcpy_trunc(entry.message.subject, subject_str.c_str());
strcpy_trunc(entry.message.body, msg_str.c_str());
strcpy_trunc(entry.message.subject, subject_str);
strcpy_trunc(entry.message.body, msg_str);
announcements[i] = entry;
i++;

View File

@ -116,5 +116,5 @@ namespace clan
struct sce_np_clans_manager
{
atomic_t<bool> is_initialized = false;
clan::clans_client* client;
std::shared_ptr<clan::clans_client> client;
};