mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
The tree's 3DS layer (the custom crt0 and link spec, system and memory setup, svchax, the old GPU command layer and the 3dsx/CIA launchers) lives under os/ctr, beside os/gekko and os/wiiu. The linear heap allocator is C: the same first-fit pool, so buffers land where they did, with live allocations found by address in an open-addressing table instead of a per-allocation tree node, and list nodes taken from cache-line-aligned slabs and reused. On the same trace it runs about half the instructions and practically no malloc/free calls. With the whole heap allocated, a further allocation now fails instead of starting the heap over and handing out its first address again, and the free-space queries no longer fault. samples/frontend/ctr_linear checks placement, alignment, coalescing, the full-heap case and pages handed back from the heap's end.
27 lines
743 B
C
27 lines
743 B
C
#include "common.h"
|
|
|
|
Handle launchOpenFile(const char* path)
|
|
{
|
|
Handle file;
|
|
Result res;
|
|
ssize_t units;
|
|
static uint16_t __utf16path[PATH_MAX+1];
|
|
|
|
if (strncmp(path, "sdmc:/", 6) == 0)
|
|
path += 5;
|
|
else if (*path != '/')
|
|
return 0;
|
|
|
|
/* Convert the executable path to UTF-16 */
|
|
units = utf8_to_utf16(__utf16path, (const uint8_t*)path, PATH_MAX);
|
|
if (units < 0 || units >= PATH_MAX) return 0;
|
|
__utf16path[units] = 0;
|
|
|
|
/* Open the file directly */
|
|
FS_Path apath = { PATH_EMPTY, 1, (u8*)"" };
|
|
FS_Path fpath = { PATH_UTF16, (units+1)*2, (u8*)__utf16path };
|
|
res = FSUSER_OpenFileDirectly(&file, ARCHIVE_SDMC,
|
|
apath, fpath, FS_OPEN_READ, 0);
|
|
return R_SUCCEEDED(res) ? file : 0;
|
|
}
|