{"action":"created","comment":{"url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/comments/223716379","pull_request_review_id":162906438,"id":223716379,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzcxNjM3OQ==","diff_hunk":"@@ -1445,34 +1429,22 @@ bool _ReadBufferFromFile(_Out_ std::string& buffer, const wchar_t* sFile)\n     return true;\n }\n \n-char* _MallocAndBulkReadFileToBuffer(const wchar_t* sFilename, long& nFileSizeOut)\n+_Use_decl_annotations_\n+char* _BulkReadFileToBuffer(const wchar_t* const sFilename, long& nFileSizeOut)\n {\n-    FILE* pf = nullptr;\n-    _wfopen_s(&pf, sFilename, L\"r\");\n-    if (pf == nullptr)\n+    nFileSizeOut = 0L;\n+    std::ifstream ifile{ sFilename, std::ios::binary };\n+    if (!ifile.is_open())\n         return nullptr;\n \n-    //\tCalculate filesize\n-    fseek(pf, 0L, SEEK_END);\n-    nFileSizeOut = ftell(pf);\n-    fseek(pf, 0L, SEEK_SET);\n-\n-    if (nFileSizeOut <= 0)\n-    {\n-        //\tNo good content in this file.\n-        fclose(pf);\n-        return nullptr;\n-    }\n+    // Calculate filesize\n+    // TODO: Put in ra::narrow_cast later\n+    nFileSizeOut = (long)(std::streamoff)ra::filesize(std::wstring{ sFilename });\n \n-    //\tmalloc() must be managed!\n     //\tNB. By adding +1, we allow for a single \\0 character :)\n-    char* pRawFileOut = (char*)malloc((nFileSizeOut + 1) * sizeof(char));\n-    ZeroMemory(pRawFileOut, nFileSizeOut + 1);\n-\n-    fread(pRawFileOut, nFileSizeOut, sizeof(char), pf);\n-    fclose(pf);\n-\n-    return pRawFileOut;\n+    auto pRawFileOut = std::make_unique<char[]>(nFileSizeOut + 1);\n+    ifile.read(pRawFileOut.get(), nFileSizeOut);\n+    return pRawFileOut.release(); // callers needs to manage it","path":"src/RA_Core.cpp","position":130,"original_position":130,"commit_id":"cb59511914a2e526554b91d46448cb44f13ab71c","original_commit_id":"c20a4511969502b00f16145824a16b638b25b5cc","user":{"login":"Jamiras","id":32680403,"node_id":"MDQ6VXNlcjMyNjgwNDAz","avatar_url":"https://avatars1.githubusercontent.com/u/32680403?v=4","gravatar_id":"","url":"https://api.github.com/users/Jamiras","html_url":"https://github.com/Jamiras","followers_url":"https://api.github.com/users/Jamiras/followers","following_url":"https://api.github.com/users/Jamiras/following{/other_user}","gists_url":"https://api.github.com/users/Jamiras/gists{/gist_id}","starred_url":"https://api.github.com/users/Jamiras/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jamiras/subscriptions","organizations_url":"https://api.github.com/users/Jamiras/orgs","repos_url":"https://api.github.com/users/Jamiras/repos","events_url":"https://api.github.com/users/Jamiras/events{/privacy}","received_events_url":"https://api.github.com/users/Jamiras/received_events","type":"User","site_admin":false},"body":"long term, this function should go away and be handled by `IFileSystem` and `TextReader`","created_at":"2018-10-09T14:08:42Z","updated_at":"2018-10-09T14:11:43Z","html_url":"https://github.com/RetroAchievements/RAIntegration/pull/134#discussion_r223716379","pull_request_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/comments/223716379"},"html":{"href":"https://github.com/RetroAchievements/RAIntegration/pull/134#discussion_r223716379"},"pull_request":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134"}},"in_reply_to_id":223533637},"pull_request":{"url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134","id":221277847,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIxMjc3ODQ3","html_url":"https://github.com/RetroAchievements/RAIntegration/pull/134","diff_url":"https://github.com/RetroAchievements/RAIntegration/pull/134.diff","patch_url":"https://github.com/RetroAchievements/RAIntegration/pull/134.patch","issue_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/134","number":134,"state":"open","locked":false,"title":"Precompiled Header","user":{"login":"SyrianBallaS","id":18649925,"node_id":"MDQ6VXNlcjE4NjQ5OTI1","avatar_url":"https://avatars2.githubusercontent.com/u/18649925?v=4","gravatar_id":"","url":"https://api.github.com/users/SyrianBallaS","html_url":"https://github.com/SyrianBallaS","followers_url":"https://api.github.com/users/SyrianBallaS/followers","following_url":"https://api.github.com/users/SyrianBallaS/following{/other_user}","gists_url":"https://api.github.com/users/SyrianBallaS/gists{/gist_id}","starred_url":"https://api.github.com/users/SyrianBallaS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SyrianBallaS/subscriptions","organizations_url":"https://api.github.com/users/SyrianBallaS/orgs","repos_url":"https://api.github.com/users/SyrianBallaS/repos","events_url":"https://api.github.com/users/SyrianBallaS/events{/privacy}","received_events_url":"https://api.github.com/users/SyrianBallaS/received_events","type":"User","site_admin":false},"body":"This PR mostly has to do w/ using a precompiled header with RA_Integration only. The unit test project does not use it. To save time, I did code analysis using `Microsoft Native Recommended Rules`. Only a small portion of what would show up with `/Wall` was addressed (from the analyzer, the rest will be addressed later. Some code analysis warnings were \"unresolvable\" so they are temporarily disabled when it happens.\r\n\r\n`685 additions and 562 deletions`, review at your leisure.\r\nThere will be review comments after this PR is submitted,","created_at":"2018-10-09T00:31:46Z","updated_at":"2018-10-09T14:11:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"72b6b2e4664715ef18fd5babb5077bf48318df5a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134/commits","review_comments_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134/comments","review_comment_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/134/comments","statuses_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/statuses/cb59511914a2e526554b91d46448cb44f13ab71c","head":{"label":"SyrianBallaS:precompiled_header","ref":"precompiled_header","sha":"cb59511914a2e526554b91d46448cb44f13ab71c","user":{"login":"SyrianBallaS","id":18649925,"node_id":"MDQ6VXNlcjE4NjQ5OTI1","avatar_url":"https://avatars2.githubusercontent.com/u/18649925?v=4","gravatar_id":"","url":"https://api.github.com/users/SyrianBallaS","html_url":"https://github.com/SyrianBallaS","followers_url":"https://api.github.com/users/SyrianBallaS/followers","following_url":"https://api.github.com/users/SyrianBallaS/following{/other_user}","gists_url":"https://api.github.com/users/SyrianBallaS/gists{/gist_id}","starred_url":"https://api.github.com/users/SyrianBallaS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SyrianBallaS/subscriptions","organizations_url":"https://api.github.com/users/SyrianBallaS/orgs","repos_url":"https://api.github.com/users/SyrianBallaS/repos","events_url":"https://api.github.com/users/SyrianBallaS/events{/privacy}","received_events_url":"https://api.github.com/users/SyrianBallaS/received_events","type":"User","site_admin":false},"repo":{"id":129931605,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk5MzE2MDU=","name":"RAIntegration","full_name":"SyrianBallaS/RAIntegration","private":false,"owner":{"login":"SyrianBallaS","id":18649925,"node_id":"MDQ6VXNlcjE4NjQ5OTI1","avatar_url":"https://avatars2.githubusercontent.com/u/18649925?v=4","gravatar_id":"","url":"https://api.github.com/users/SyrianBallaS","html_url":"https://github.com/SyrianBallaS","followers_url":"https://api.github.com/users/SyrianBallaS/followers","following_url":"https://api.github.com/users/SyrianBallaS/following{/other_user}","gists_url":"https://api.github.com/users/SyrianBallaS/gists{/gist_id}","starred_url":"https://api.github.com/users/SyrianBallaS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SyrianBallaS/subscriptions","organizations_url":"https://api.github.com/users/SyrianBallaS/orgs","repos_url":"https://api.github.com/users/SyrianBallaS/repos","events_url":"https://api.github.com/users/SyrianBallaS/events{/privacy}","received_events_url":"https://api.github.com/users/SyrianBallaS/received_events","type":"User","site_admin":false},"html_url":"https://github.com/SyrianBallaS/RAIntegration","description":"The DLL responsible to integrate emulators with RetroAchievements.org","fork":true,"url":"https://api.github.com/repos/SyrianBallaS/RAIntegration","forks_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/forks","keys_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/teams","hooks_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/hooks","issue_events_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/issues/events{/number}","events_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/events","assignees_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/assignees{/user}","branches_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/branches{/branch}","tags_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/tags","blobs_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/git/refs{/sha}","trees_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/statuses/{sha}","languages_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/languages","stargazers_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/stargazers","contributors_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/contributors","subscribers_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/subscribers","subscription_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/subscription","commits_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/commits{/sha}","git_commits_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/git/commits{/sha}","comments_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/comments{/number}","issue_comment_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/issues/comments{/number}","contents_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/contents/{+path}","compare_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/merges","archive_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/downloads","issues_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/issues{/number}","pulls_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/pulls{/number}","milestones_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/milestones{/number}","notifications_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/labels{/name}","releases_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/releases{/id}","deployments_url":"https://api.github.com/repos/SyrianBallaS/RAIntegration/deployments","created_at":"2018-04-17T16:09:30Z","updated_at":"2018-10-05T22:24:30Z","pushed_at":"2018-10-09T01:37:58Z","git_url":"git://github.com/SyrianBallaS/RAIntegration.git","ssh_url":"git@github.com:SyrianBallaS/RAIntegration.git","clone_url":"https://github.com/SyrianBallaS/RAIntegration.git","svn_url":"https://github.com/SyrianBallaS/RAIntegration","homepage":"http://retroachievements.org","size":3189,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RetroAchievements:master","ref":"master","sha":"bcc6a3a11a7a8df051c2f9861e8fad40dd2cd7a3","user":{"login":"RetroAchievements","id":5411318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MTEzMTg=","avatar_url":"https://avatars3.githubusercontent.com/u/5411318?v=4","gravatar_id":"","url":"https://api.github.com/users/RetroAchievements","html_url":"https://github.com/RetroAchievements","followers_url":"https://api.github.com/users/RetroAchievements/followers","following_url":"https://api.github.com/users/RetroAchievements/following{/other_user}","gists_url":"https://api.github.com/users/RetroAchievements/gists{/gist_id}","starred_url":"https://api.github.com/users/RetroAchievements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RetroAchievements/subscriptions","organizations_url":"https://api.github.com/users/RetroAchievements/orgs","repos_url":"https://api.github.com/users/RetroAchievements/repos","events_url":"https://api.github.com/users/RetroAchievements/events{/privacy}","received_events_url":"https://api.github.com/users/RetroAchievements/received_events","type":"Organization","site_admin":false},"repo":{"id":129603848,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk2MDM4NDg=","name":"RAIntegration","full_name":"RetroAchievements/RAIntegration","private":false,"owner":{"login":"RetroAchievements","id":5411318,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MTEzMTg=","avatar_url":"https://avatars3.githubusercontent.com/u/5411318?v=4","gravatar_id":"","url":"https://api.github.com/users/RetroAchievements","html_url":"https://github.com/RetroAchievements","followers_url":"https://api.github.com/users/RetroAchievements/followers","following_url":"https://api.github.com/users/RetroAchievements/following{/other_user}","gists_url":"https://api.github.com/users/RetroAchievements/gists{/gist_id}","starred_url":"https://api.github.com/users/RetroAchievements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RetroAchievements/subscriptions","organizations_url":"https://api.github.com/users/RetroAchievements/orgs","repos_url":"https://api.github.com/users/RetroAchievements/repos","events_url":"https://api.github.com/users/RetroAchievements/events{/privacy}","received_events_url":"https://api.github.com/users/RetroAchievements/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/RetroAchievements/RAIntegration","description":"The DLL responsible to integrate emulators with RetroAchievements.org","fork":false,"url":"https://api.github.com/repos/RetroAchievements/RAIntegration","forks_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/forks","keys_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/teams","hooks_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/hooks","issue_events_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/events{/number}","events_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/events","assignees_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/assignees{/user}","branches_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/branches{/branch}","tags_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/tags","blobs_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/git/refs{/sha}","trees_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/statuses/{sha}","languages_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/languages","stargazers_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/stargazers","contributors_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/contributors","subscribers_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/subscribers","subscription_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/subscription","commits_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/commits{/sha}","git_commits_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/git/commits{/sha}","comments_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/comments{/number}","issue_comment_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/comments{/number}","contents_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/contents/{+path}","compare_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/merges","archive_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/downloads","issues_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues{/number}","pulls_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls{/number}","milestones_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/milestones{/number}","notifications_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/labels{/name}","releases_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/releases{/id}","deployments_url":"https://api.github.com/repos/RetroAchievements/RAIntegration/deployments","created_at":"2018-04-15T11:33:17Z","updated_at":"2018-10-05T21:42:10Z","pushed_at":"2018-10-09T01:37:59Z","git_url":"git://github.com/RetroAchievements/RAIntegration.git","ssh_url":"git@github.com:RetroAchievements/RAIntegration.git","clone_url":"https://github.com/RetroAchievements/RAIntegration.git","svn_url":"https://github.com/RetroAchievements/RAIntegration","homepage":"http://retroachievements.org","size":2839,"stargazers_count":12,"watchers_count":12,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":44,"license":null,"forks":5,"open_issues":44,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134"},"html":{"href":"https://github.com/RetroAchievements/RAIntegration/pull/134"},"issue":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/134"},"comments":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/issues/134/comments"},"review_comments":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134/comments"},"review_comment":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/pulls/134/commits"},"statuses":{"href":"https://api.github.com/repos/RetroAchievements/RAIntegration/statuses/cb59511914a2e526554b91d46448cb44f13ab71c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Jamiras"}}