mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-10 03:31:30 -06:00
Refactor memory allocation and deallocation calls to remove Core::ExecuteGuest wrapper
This commit is contained in:
parent
8b44502b1d
commit
243c40cf9f
@ -160,7 +160,7 @@ s32 PS4_SYSV_ABI sceFontAttachDeviceCacheBuffer(OrbisFontLib library, void* buff
|
||||
} else {
|
||||
u32* header = static_cast<u32*>(buffer);
|
||||
if (!header) {
|
||||
header = static_cast<u32*>(Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, size));
|
||||
header = static_cast<u32*>(alloc_fn(lib->alloc_ctx, size));
|
||||
if (!header) {
|
||||
cache_to_store = nullptr;
|
||||
rc = ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
@ -191,7 +191,7 @@ s32 PS4_SYSV_ABI sceFontAttachDeviceCacheBuffer(OrbisFontLib library, void* buff
|
||||
}
|
||||
} else {
|
||||
if (!buffer) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, header);
|
||||
free_fn(lib->alloc_ctx, header);
|
||||
}
|
||||
cache_to_store = nullptr;
|
||||
rc = ORBIS_FONT_ERROR_INVALID_PARAMETER;
|
||||
@ -481,15 +481,15 @@ s32 PS4_SYSV_ABI sceFontCreateLibraryWithEdition(const OrbisFontMem* memory,
|
||||
return ORBIS_FONT_ERROR_INVALID_MEMORY;
|
||||
}
|
||||
|
||||
void* lib_mem = Core::ExecuteGuest(malloc_fn, memory->mspace_handle, 0x100);
|
||||
void* lib_mem = malloc_fn(memory->mspace_handle, 0x100);
|
||||
if (!lib_mem) {
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
void* mspace = Core::ExecuteGuest(malloc_fn, memory->mspace_handle, 0x4000);
|
||||
void* mspace = malloc_fn(memory->mspace_handle, 0x4000);
|
||||
if (!mspace) {
|
||||
Core::ExecuteGuest(free_fn, memory->mspace_handle, lib_mem);
|
||||
free_fn(memory->mspace_handle, lib_mem);
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
@ -546,8 +546,8 @@ s32 PS4_SYSV_ABI sceFontCreateLibraryWithEdition(const OrbisFontMem* memory,
|
||||
|
||||
const s32 init_rc = init_fn(memory, lib);
|
||||
if (init_rc != ORBIS_OK) {
|
||||
Core::ExecuteGuest(free_fn, memory->mspace_handle, mspace);
|
||||
Core::ExecuteGuest(free_fn, memory->mspace_handle, lib_mem);
|
||||
free_fn(memory->mspace_handle, mspace);
|
||||
free_fn(memory->mspace_handle, lib_mem);
|
||||
LOG_ERROR(Lib_Font, "INIT_FAILED");
|
||||
return init_rc;
|
||||
}
|
||||
@ -626,7 +626,7 @@ s32 PS4_SYSV_ABI sceFontDestroyLibrary(OrbisFontLib* pLibrary) {
|
||||
? reinterpret_cast<Internal::FontFreeFn>(native->alloc_vtbl[1])
|
||||
: nullptr;
|
||||
if (free_fn) {
|
||||
Core::ExecuteGuest(free_fn, native->alloc_ctx, native);
|
||||
free_fn(native->alloc_ctx, native);
|
||||
} else {
|
||||
std::free(native);
|
||||
}
|
||||
@ -680,8 +680,8 @@ s32 PS4_SYSV_ABI sceFontCreateRendererWithEdition(const OrbisFontMem* memory,
|
||||
create_params);
|
||||
const u32 render_size = selection ? selection->size : 0u;
|
||||
void* renderer_mem =
|
||||
Core::ExecuteGuest(alloc_fn, memory->mspace_handle, render_size);
|
||||
void* workspace = Core::ExecuteGuest(alloc_fn, memory->mspace_handle, 0x4000);
|
||||
alloc_fn(memory->mspace_handle, render_size);
|
||||
void* workspace = alloc_fn(memory->mspace_handle, 0x4000);
|
||||
|
||||
rc = ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
if (renderer_mem && workspace) {
|
||||
@ -720,7 +720,7 @@ s32 PS4_SYSV_ABI sceFontCreateRendererWithEdition(const OrbisFontMem* memory,
|
||||
if (!create_fn) {
|
||||
rc = ORBIS_FONT_ERROR_FATAL;
|
||||
} else {
|
||||
rc = Core::ExecuteGuest(create_fn, renderer_mem);
|
||||
rc = create_fn(renderer_mem);
|
||||
if (rc == ORBIS_OK) {
|
||||
s32 sdk_version = 0;
|
||||
u32 sdk_version_u32 = 0;
|
||||
@ -748,10 +748,10 @@ s32 PS4_SYSV_ABI sceFontCreateRendererWithEdition(const OrbisFontMem* memory,
|
||||
}
|
||||
|
||||
if (workspace) {
|
||||
Core::ExecuteGuest(free_fn, memory->mspace_handle, workspace);
|
||||
free_fn(memory->mspace_handle, workspace);
|
||||
}
|
||||
if (renderer_mem) {
|
||||
Core::ExecuteGuest(free_fn, memory->mspace_handle, renderer_mem);
|
||||
free_fn(memory->mspace_handle, renderer_mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -875,7 +875,7 @@ s32 PS4_SYSV_ABI sceFontDestroyRenderer(OrbisFontRenderer* pRenderer) {
|
||||
if (destroy_fn_ptr == kFtRendererDestroyFnAddr) {
|
||||
destroy_fn = &Libraries::FontFt::Internal::FtRendererDestroy;
|
||||
}
|
||||
rc = destroy_fn ? Core::ExecuteGuest(destroy_fn, renderer) : ORBIS_FONT_ERROR_FATAL;
|
||||
rc = destroy_fn ? destroy_fn(renderer) : ORBIS_FONT_ERROR_FATAL;
|
||||
}
|
||||
|
||||
renderer->selection = nullptr;
|
||||
@ -884,9 +884,9 @@ s32 PS4_SYSV_ABI sceFontDestroyRenderer(OrbisFontRenderer* pRenderer) {
|
||||
void* alloc_ctx = renderer->alloc_ctx;
|
||||
void* workspace = renderer->workspace;
|
||||
if (workspace) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, workspace);
|
||||
free_fn(alloc_ctx, workspace);
|
||||
}
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, renderer);
|
||||
free_fn(alloc_ctx, renderer);
|
||||
|
||||
*pRenderer = nullptr;
|
||||
return rc;
|
||||
@ -1973,7 +1973,7 @@ s32 PS4_SYSV_ABI sceFontMemoryTerm(OrbisFontMem* mem_desc) {
|
||||
reinterpret_cast<void(PS4_SYSV_ABI*)(void* parent, void* mspace)>(
|
||||
mem_desc->iface->mspace_destroy);
|
||||
if (destroy_fn) {
|
||||
Core::ExecuteGuest(destroy_fn, mem_desc->some_ctx2, mem_desc->mspace_handle);
|
||||
destroy_fn(mem_desc->some_ctx2, mem_desc->mspace_handle);
|
||||
}
|
||||
}
|
||||
std::memset(mem_desc, 0, sizeof(*mem_desc));
|
||||
@ -1984,7 +1984,7 @@ s32 PS4_SYSV_ABI sceFontMemoryTerm(OrbisFontMem* mem_desc) {
|
||||
mem_desc->mem_kind = 0;
|
||||
const auto destroy_fn = reinterpret_cast<void(PS4_SYSV_ABI*)(
|
||||
OrbisFontMem * fontMemory, void* object, void* destroyArg)>(mem_desc->on_destroy);
|
||||
Core::ExecuteGuest(destroy_fn, mem_desc, mem_desc->mspace_handle, mem_desc->destroy_ctx);
|
||||
destroy_fn(mem_desc, mem_desc->mspace_handle, mem_desc->destroy_ctx);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
@ -2087,7 +2087,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontFile(OrbisFontLib library, const char* guest_pat
|
||||
}
|
||||
Internal::RemoveState(handle);
|
||||
} else {
|
||||
handle = static_cast<OrbisFontHandle>(Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, 0x100));
|
||||
handle = static_cast<OrbisFontHandle>(alloc_fn(lib->alloc_ctx, 0x100));
|
||||
if (!handle) {
|
||||
release_library_and_clear_out();
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
@ -2117,7 +2117,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontFile(OrbisFontLib library, const char* guest_pat
|
||||
const u16 prev_flags = h->flags;
|
||||
h->flags = 0;
|
||||
if ((prev_flags & 0x10) != 0) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, handle);
|
||||
free_fn(lib->alloc_ctx, handle);
|
||||
}
|
||||
Internal::RemoveState(handle);
|
||||
ReleaseLibraryLock(lib, prev_lib_lock);
|
||||
@ -2586,7 +2586,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontInstance(OrbisFontHandle fontHandle, OrbisFontHa
|
||||
return ORBIS_FONT_ERROR_INVALID_FONT_HANDLE;
|
||||
}
|
||||
out_handle =
|
||||
static_cast<OrbisFontHandle>(Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, 0x100));
|
||||
static_cast<OrbisFontHandle>(alloc_fn(lib->alloc_ctx, 0x100));
|
||||
if (!out_handle) {
|
||||
release_src_lock();
|
||||
if (pFontHandle) {
|
||||
@ -2620,7 +2620,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontInstance(OrbisFontHandle fontHandle, OrbisFontHa
|
||||
if (!entries_base || entry_count > max_entries) {
|
||||
dst->magic = 0;
|
||||
if (owned && free_fn) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, out_handle);
|
||||
free_fn(lib->alloc_ctx, out_handle);
|
||||
}
|
||||
release_src_lock();
|
||||
if (pFontHandle) {
|
||||
@ -2773,7 +2773,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontInstance(OrbisFontHandle fontHandle, OrbisFontHa
|
||||
const u16 prev_flags = dst->flags;
|
||||
dst->flags = 0;
|
||||
if ((prev_flags & 0x10) != 0 && free_fn) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, out_handle);
|
||||
free_fn(lib->alloc_ctx, out_handle);
|
||||
}
|
||||
Internal::RemoveState(out_handle);
|
||||
|
||||
@ -2969,7 +2969,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontMemory(OrbisFontLib library, const void* fontAdd
|
||||
}
|
||||
Internal::RemoveState(handle);
|
||||
} else {
|
||||
handle = static_cast<OrbisFontHandle>(Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, 0x100));
|
||||
handle = static_cast<OrbisFontHandle>(alloc_fn(lib->alloc_ctx, 0x100));
|
||||
if (!handle) {
|
||||
release_library_and_clear_out();
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
@ -2999,7 +2999,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontMemory(OrbisFontLib library, const void* fontAdd
|
||||
const u16 prev_flags = h->flags;
|
||||
h->flags = 0;
|
||||
if ((prev_flags & 0x10) != 0) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, handle);
|
||||
free_fn(lib->alloc_ctx, handle);
|
||||
}
|
||||
Internal::RemoveState(handle);
|
||||
ReleaseLibraryLock(lib, prev_lib_lock);
|
||||
@ -3386,7 +3386,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontSet(OrbisFontLib library, u32 fontSetType, u32 o
|
||||
Internal::RemoveState(handle);
|
||||
} else {
|
||||
handle = static_cast<OrbisFontHandle>(
|
||||
Core::ExecuteGuest(alloc_fn, lib_local->alloc_ctx, 0x100));
|
||||
alloc_fn(lib_local->alloc_ctx, 0x100));
|
||||
if (!handle) {
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
return release_library_and_clear_out(ORBIS_FONT_ERROR_ALLOCATION_FAILED);
|
||||
@ -3414,7 +3414,7 @@ s32 PS4_SYSV_ABI sceFontOpenFontSet(OrbisFontLib library, u32 fontSetType, u32 o
|
||||
h->library = library;
|
||||
h->flags = 0;
|
||||
if ((prev_flags & 0x10) != 0) {
|
||||
Core::ExecuteGuest(free_fn, lib_local->alloc_ctx, handle);
|
||||
free_fn(lib_local->alloc_ctx, handle);
|
||||
}
|
||||
Internal::RemoveState(handle);
|
||||
return release_library_and_clear_out(rc);
|
||||
@ -4852,14 +4852,14 @@ s32 PS4_SYSV_ABI sceFontRendererSetOutlineBufferPolicy(OrbisFontRenderer fontRen
|
||||
|
||||
if (!renderer->workspace || renderer->workspace_size != desired_size) {
|
||||
void* new_workspace =
|
||||
Core::ExecuteGuest(alloc_fn, renderer->alloc_ctx, static_cast<u32>(desired_size));
|
||||
alloc_fn(renderer->alloc_ctx, static_cast<u32>(desired_size));
|
||||
if (!new_workspace) {
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
|
||||
if (renderer->workspace) {
|
||||
Core::ExecuteGuest(free_fn, renderer->alloc_ctx, renderer->workspace);
|
||||
free_fn(renderer->alloc_ctx, renderer->workspace);
|
||||
}
|
||||
|
||||
renderer->workspace = new_workspace;
|
||||
@ -5697,7 +5697,7 @@ s32 PS4_SYSV_ABI sceFontSupportExternalFonts(OrbisFontLib library, u32 fontMax,
|
||||
}
|
||||
|
||||
const u32 ctx_size = (fontMax << 6) | 0x20u;
|
||||
void* ctx = Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, ctx_size);
|
||||
void* ctx = alloc_fn(lib->alloc_ctx, ctx_size);
|
||||
if (!ctx) {
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
@ -5725,14 +5725,14 @@ s32 PS4_SYSV_ABI sceFontSupportExternalFonts(OrbisFontLib library, u32 fontMax,
|
||||
lib->sys_driver ? reinterpret_cast<const Internal::SysDriver*>(lib->sys_driver) : nullptr;
|
||||
const auto support_fn = driver ? driver->support_formats : nullptr;
|
||||
if (!support_fn) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, ctx);
|
||||
free_fn(lib->alloc_ctx, ctx);
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "INVALID_LIBRARY");
|
||||
return ORBIS_FONT_ERROR_INVALID_LIBRARY;
|
||||
}
|
||||
const s32 support_rc = support_fn(library, formats);
|
||||
if (support_rc != ORBIS_OK) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, ctx);
|
||||
free_fn(lib->alloc_ctx, ctx);
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "SUPPORT_FAILED");
|
||||
return support_rc;
|
||||
@ -5790,7 +5790,7 @@ s32 PS4_SYSV_ABI sceFontSupportSystemFonts(OrbisFontLib library) {
|
||||
}
|
||||
|
||||
constexpr u32 kSysCtxSize = 0x1020;
|
||||
void* ctx = Core::ExecuteGuest(alloc_fn, lib->alloc_ctx, kSysCtxSize);
|
||||
void* ctx = alloc_fn(lib->alloc_ctx, kSysCtxSize);
|
||||
if (!ctx) {
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "ALLOCATION_FAILED");
|
||||
@ -5812,14 +5812,14 @@ s32 PS4_SYSV_ABI sceFontSupportSystemFonts(OrbisFontLib library) {
|
||||
lib->sys_driver ? reinterpret_cast<const Internal::SysDriver*>(lib->sys_driver) : nullptr;
|
||||
const auto support_fn = driver ? driver->support_formats : nullptr;
|
||||
if (!support_fn) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, ctx);
|
||||
free_fn(lib->alloc_ctx, ctx);
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "INVALID_LIBRARY");
|
||||
return ORBIS_FONT_ERROR_INVALID_LIBRARY;
|
||||
}
|
||||
const s32 support_rc = support_fn(library, 0x52);
|
||||
if (support_rc != ORBIS_OK) {
|
||||
Core::ExecuteGuest(free_fn, lib->alloc_ctx, ctx);
|
||||
free_fn(lib->alloc_ctx, ctx);
|
||||
ReleaseLibraryLock(lib, prev_lock_word);
|
||||
LOG_ERROR(Lib_Font, "SUPPORT_FAILED");
|
||||
return support_rc;
|
||||
@ -6385,3 +6385,4 @@ void RegisterlibSceFont(Core::Loader::SymbolsResolver* sym) {
|
||||
};
|
||||
|
||||
} // namespace Libraries::Font
|
||||
|
||||
|
||||
@ -576,7 +576,7 @@ void RemoveLibState(Libraries::Font::OrbisFontLib lib) {
|
||||
if (free_fn) {
|
||||
const auto free_fn_guest =
|
||||
reinterpret_cast<void(PS4_SYSV_ABI*)(void* object, void* p)>(free_fn);
|
||||
Core::ExecuteGuest(free_fn_guest, alloc_ctx, p);
|
||||
free_fn_guest(alloc_ctx, p);
|
||||
return;
|
||||
}
|
||||
std::free(p);
|
||||
@ -1916,3 +1916,4 @@ void CachedStyleSetScalar(Libraries::Font::OrbisFontStyleFrame& cached_style, fl
|
||||
std::memcpy(&cached_style.cached_scalar_bits, &value, sizeof(value));
|
||||
}
|
||||
} // namespace Libraries::Font::Internal
|
||||
|
||||
|
||||
@ -2560,7 +2560,7 @@ static void* FtAlloc(FT_Memory memory, long size) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto alloc_fn = reinterpret_cast<GuestAllocFn>(ctx->alloc_vtbl[0]);
|
||||
return alloc_fn ? Core::ExecuteGuest(alloc_fn, ctx->alloc_ctx, static_cast<u32>(size))
|
||||
return alloc_fn ? alloc_fn(ctx->alloc_ctx, static_cast<u32>(size))
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
@ -2574,7 +2574,7 @@ static void FtFree(FT_Memory memory, void* block) {
|
||||
}
|
||||
const auto free_fn = reinterpret_cast<GuestFreeFn>(ctx->alloc_vtbl[1]);
|
||||
if (free_fn) {
|
||||
Core::ExecuteGuest(free_fn, ctx->alloc_ctx, block);
|
||||
free_fn(ctx->alloc_ctx, block);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2588,7 +2588,7 @@ static void* FtRealloc(FT_Memory memory, long cur_size, long new_size, void* blo
|
||||
}
|
||||
const auto realloc_fn = reinterpret_cast<GuestReallocFn>(ctx->alloc_vtbl[2]);
|
||||
if (realloc_fn) {
|
||||
return Core::ExecuteGuest(realloc_fn, ctx->alloc_ctx, block, static_cast<u32>(new_size));
|
||||
return realloc_fn(ctx->alloc_ctx, block, static_cast<u32>(new_size));
|
||||
}
|
||||
|
||||
if (new_size <= 0) {
|
||||
@ -2680,7 +2680,7 @@ s32 PS4_SYSV_ABI LibraryInitStub(const void* memory, void* library) {
|
||||
reinterpret_cast<void**>(const_cast<Libraries::Font::OrbisFontMemInterface*>(mem->iface));
|
||||
|
||||
auto* ctx =
|
||||
static_cast<FtLibraryCtx*>(Core::ExecuteGuest(alloc_fn, alloc_ctx, sizeof(FtLibraryCtx)));
|
||||
static_cast<FtLibraryCtx*>(alloc_fn(alloc_ctx, sizeof(FtLibraryCtx)));
|
||||
if (!ctx) {
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
@ -2689,9 +2689,9 @@ s32 PS4_SYSV_ABI LibraryInitStub(const void* memory, void* library) {
|
||||
ctx->alloc_vtbl = alloc_vtbl;
|
||||
|
||||
FT_Memory ft_mem =
|
||||
static_cast<FT_Memory>(Core::ExecuteGuest(alloc_fn, alloc_ctx, sizeof(FT_MemoryRec_)));
|
||||
static_cast<FT_Memory>(alloc_fn(alloc_ctx, sizeof(FT_MemoryRec_)));
|
||||
if (!ft_mem) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, ctx);
|
||||
free_fn(alloc_ctx, ctx);
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
std::memset(ft_mem, 0, sizeof(*ft_mem));
|
||||
@ -2704,8 +2704,8 @@ s32 PS4_SYSV_ABI LibraryInitStub(const void* memory, void* library) {
|
||||
FT_Library ft_lib = nullptr;
|
||||
const FT_Error ft_err = FT_New_Library(ft_mem, &ft_lib);
|
||||
if (ft_err != 0 || !ft_lib) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, ft_mem);
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, ctx);
|
||||
free_fn(alloc_ctx, ft_mem);
|
||||
free_fn(alloc_ctx, ctx);
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
FT_Add_Default_Modules(ft_lib);
|
||||
@ -2774,10 +2774,10 @@ s32 PS4_SYSV_ABI LibraryTermStub(void* library) {
|
||||
ctx->ft_lib = nullptr;
|
||||
}
|
||||
if (ctx->ft_memory) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, ctx->ft_memory);
|
||||
free_fn(alloc_ctx, ctx->ft_memory);
|
||||
ctx->ft_memory = nullptr;
|
||||
}
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, ctx);
|
||||
free_fn(alloc_ctx, ctx);
|
||||
lib->fontset_registry = nullptr;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
@ -2878,7 +2878,7 @@ s32 PS4_SYSV_ABI LibraryOpenFontMemoryStub(void* library, u32 mode, const void*
|
||||
auto* ctx = static_cast<FtLibraryCtx*>(lib->fontset_registry);
|
||||
if (!ctx || !ctx->ft_lib) {
|
||||
if (owned_data) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, owned_data);
|
||||
free_fn(alloc_ctx, owned_data);
|
||||
}
|
||||
return ORBIS_FONT_ERROR_INVALID_LIBRARY;
|
||||
}
|
||||
@ -2930,7 +2930,7 @@ s32 PS4_SYSV_ABI LibraryOpenFontMemoryStub(void* library, u32 mode, const void*
|
||||
}
|
||||
if (ft_err != 0 || !face) {
|
||||
if (owned_data) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, owned_data);
|
||||
free_fn(alloc_ctx, owned_data);
|
||||
}
|
||||
if (mode == 1) {
|
||||
return ORBIS_FONT_ERROR_NO_SUPPORT_FORMAT;
|
||||
@ -2943,11 +2943,11 @@ s32 PS4_SYSV_ABI LibraryOpenFontMemoryStub(void* library, u32 mode, const void*
|
||||
|
||||
(void)FT_Select_Charmap(face, FT_ENCODING_UNICODE);
|
||||
|
||||
auto* obj = static_cast<FontObj*>(Core::ExecuteGuest(alloc_fn, alloc_ctx, sizeof(FontObj)));
|
||||
auto* obj = static_cast<FontObj*>(alloc_fn(alloc_ctx, sizeof(FontObj)));
|
||||
if (!obj) {
|
||||
FT_Done_Face(face);
|
||||
if (owned_data) {
|
||||
Core::ExecuteGuest(free_fn, alloc_ctx, owned_data);
|
||||
free_fn(alloc_ctx, owned_data);
|
||||
}
|
||||
return ORBIS_FONT_ERROR_ALLOCATION_FAILED;
|
||||
}
|
||||
@ -3010,7 +3010,7 @@ s32 PS4_SYSV_ABI LibraryCloseFontObjStub(void* fontObj, u32 /*flags*/) {
|
||||
obj->ft_face = nullptr;
|
||||
}
|
||||
if (owned_data && free_fn) {
|
||||
Core::ExecuteGuest(free_fn, ctx->alloc_ctx, owned_data);
|
||||
free_fn(ctx->alloc_ctx, owned_data);
|
||||
}
|
||||
if (free_fn) {
|
||||
FontObj* next = obj->next;
|
||||
@ -3021,7 +3021,7 @@ s32 PS4_SYSV_ABI LibraryCloseFontObjStub(void* fontObj, u32 /*flags*/) {
|
||||
} else {
|
||||
obj->prev->next = next;
|
||||
}
|
||||
Core::ExecuteGuest(free_fn, ctx->alloc_ctx, obj);
|
||||
free_fn(ctx->alloc_ctx, obj);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
return ORBIS_FONT_ERROR_FATAL;
|
||||
@ -3604,3 +3604,4 @@ s32 PS4_SYSV_ABI LibraryConfigureGlyphStub(void* fontObj, std::uint32_t* in_para
|
||||
}
|
||||
|
||||
} // namespace Libraries::FontFt::Internal
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user