Skip to content

Commit

Permalink
remove unnecessary memset calls by replacing strcat with sprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
ioistired committed Aug 21, 2020
1 parent 7a4a6c9 commit c5a9715
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions sysmodules/rosalina/source/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,7 @@ void RosalinaMenu_TakeScreenshot(void)
Result res = 0;

char directory[32];
memset(directory, 0, sizeof directory);
char filename[90];
memset(filename, 0, sizeof filename);

FS_Archive archive;
FS_ArchiveID archiveId;
Expand Down Expand Up @@ -416,7 +414,7 @@ void RosalinaMenu_TakeScreenshot(void)
res = FSUSER_OpenArchive(&archive, archiveId, fsMakePath(PATH_EMPTY, ""));
if(R_SUCCEEDED(res))
{
strcat(directory, "/luma/screenshots");
sprintf(directory, "/luma/screenshots");
char dirName[16];
#define CREATE_SUBDIR(length, name) do { \
sprintf(dirName, "/%0" #length "lu", name); \
Expand All @@ -440,7 +438,12 @@ void RosalinaMenu_TakeScreenshot(void)
res = PMDBG_GetCurrentAppInfo(&programInfo, &unused, &unused);

#define WRITE_SCREENSHOT(screenName, screenWidth, top, left) do { \
sprintf(filename, "%s/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_%016llx_" screenName ".bmp", directory, year, month, days, hours, minutes, seconds, milliseconds, programInfo.programId); \
sprintf( \
filename, \
"%s/%04lu-%02lu-%02lu_%02lu-%02lu-%02lu.%03llu_%016llx_%s.bmp", \
directory, \
year, month, days, hours, minutes, seconds, milliseconds, \
programInfo.programId, screenName); \
TRY(IFile_Open(&file, archiveId, fsMakePath(PATH_EMPTY, ""), fsMakePath(PATH_ASCII, filename), FS_OPEN_CREATE | FS_OPEN_WRITE)); \
TRY(RosalinaMenu_WriteScreenshot(&file, screenWidth, top, left)); \
TRY(IFile_Close(&file)); \
Expand Down

0 comments on commit c5a9715

Please sign in to comment.