{"action":"created","comment":{"url":"https://api.github.com/repos/mdaus/coda-oss/pulls/comments/218024987","pull_request_review_id":155869448,"id":218024987,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODAyNDk4Nw==","diff_hunk":"@@ -0,0 +1,95 @@\n+/* =========================================================================\n+ * This file is part of mem-c++\n+ * =========================================================================\n+ *\n+ * (C) Copyright 2004 - 2018, MDA Information Systems LLC\n+ *\n+ * mem-c++ is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU Lesser General Public License as published by\n+ * the Free Software Foundation; either version 3 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU Lesser General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU Lesser General Public\n+ * License along with this program; If not,\n+ * see <http://www.gnu.org/licenses/>.\n+ *\n+ */\n+\n+namespace mem\n+{\n+template <typename T>\n+void ScratchMemory::put(const std::string& key,\n+                        size_t numElements,\n+                        size_t numBuffers,\n+                        size_t alignment)\n+{\n+    put<sys::ubyte>(key, numElements * sizeof(T), numBuffers, alignment);\n+}\n+\n+template <>\n+inline void ScratchMemory::put<sys::ubyte>(const std::string& key,\n+                                           size_t numElements,\n+                                           size_t numBuffers,\n+                                           size_t alignment)\n+{\n+    // invalidate buffer (setup must be called before any subsequent get call)\n+    mBuffer.data = NULL;\n+\n+    alignment = std::max<size_t>(1, alignment);\n+    mNumBytesNeeded += numBuffers * (numElements + alignment - 1);\n+\n+    std::map<std::string, Segment>::iterator iterSeg = mSegments.find(key);\n+    if (iterSeg != mSegments.end())\n+    {\n+        std::ostringstream oss;\n+        oss << \"Scratch memory space was already reserved for \" << key;\n+        throw except::Exception(Ctxt(oss.str()));\n+    }\n+    mSegments.insert(\n+            iterSeg,\n+            std::make_pair(key, Segment(numElements, numBuffers, alignment)));\n+}\n+\n+template <typename T>\n+T* ScratchMemory::get(const std::string& key, size_t indexBuffer)\n+{\n+    return const_cast<T*>(\n+            const_cast<const ScratchMemory&>(*this).get<T>(key, indexBuffer));","path":"modules/c++/mem/include/mem/ScratchMemory.hpp","position":62,"original_position":62,"commit_id":"5a75b155fdf2e6d9b8fc7092eec97ecd9f59a456","original_commit_id":"5a75b155fdf2e6d9b8fc7092eec97ecd9f59a456","user":{"login":"clydestanfield","id":11978520,"node_id":"MDQ6VXNlcjExOTc4NTIw","avatar_url":"https://avatars1.githubusercontent.com/u/11978520?v=4","gravatar_id":"","url":"https://api.github.com/users/clydestanfield","html_url":"https://github.com/clydestanfield","followers_url":"https://api.github.com/users/clydestanfield/followers","following_url":"https://api.github.com/users/clydestanfield/following{/other_user}","gists_url":"https://api.github.com/users/clydestanfield/gists{/gist_id}","starred_url":"https://api.github.com/users/clydestanfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clydestanfield/subscriptions","organizations_url":"https://api.github.com/users/clydestanfield/orgs","repos_url":"https://api.github.com/users/clydestanfield/repos","events_url":"https://api.github.com/users/clydestanfield/events{/privacy}","received_events_url":"https://api.github.com/users/clydestanfield/received_events","type":"User","site_admin":false},"body":"Typically we try to avoid const cast where possible. What if instead of this we add a private method that handles the error checking and returns a `const Segment&`. We could then call that common method in both version and then only need a reinterpret_cast.","created_at":"2018-09-17T10:53:18Z","updated_at":"2018-09-17T10:53:18Z","html_url":"https://github.com/mdaus/coda-oss/pull/267#discussion_r218024987","pull_request_url":"https://api.github.com/repos/mdaus/coda-oss/pulls/267","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/comments/218024987"},"html":{"href":"https://github.com/mdaus/coda-oss/pull/267#discussion_r218024987"},"pull_request":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/267"}}},"pull_request":{"url":"https://api.github.com/repos/mdaus/coda-oss/pulls/267","id":215637814,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1NjM3ODE0","html_url":"https://github.com/mdaus/coda-oss/pull/267","diff_url":"https://github.com/mdaus/coda-oss/pull/267.diff","patch_url":"https://github.com/mdaus/coda-oss/pull/267.patch","issue_url":"https://api.github.com/repos/mdaus/coda-oss/issues/267","number":267,"state":"open","locked":false,"title":"Class to handle reservation of scratch memory segments with optional alignment","user":{"login":"kdwilhelm","id":1964653,"node_id":"MDQ6VXNlcjE5NjQ2NTM=","avatar_url":"https://avatars0.githubusercontent.com/u/1964653?v=4","gravatar_id":"","url":"https://api.github.com/users/kdwilhelm","html_url":"https://github.com/kdwilhelm","followers_url":"https://api.github.com/users/kdwilhelm/followers","following_url":"https://api.github.com/users/kdwilhelm/following{/other_user}","gists_url":"https://api.github.com/users/kdwilhelm/gists{/gist_id}","starred_url":"https://api.github.com/users/kdwilhelm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdwilhelm/subscriptions","organizations_url":"https://api.github.com/users/kdwilhelm/orgs","repos_url":"https://api.github.com/users/kdwilhelm/repos","events_url":"https://api.github.com/users/kdwilhelm/events{/privacy}","received_events_url":"https://api.github.com/users/kdwilhelm/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-14T15:51:01Z","updated_at":"2018-09-17T10:53:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"71ca2097767f50360253f77cb960a97ccf444167","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/mdaus/coda-oss/milestones/8","html_url":"https://github.com/mdaus/coda-oss/milestone/8","labels_url":"https://api.github.com/repos/mdaus/coda-oss/milestones/8/labels","id":3621492,"node_id":"MDk6TWlsZXN0b25lMzYyMTQ5Mg==","number":8,"title":"CODA 18.09","description":"","creator":{"login":"asylvest","id":11707082,"node_id":"MDQ6VXNlcjExNzA3MDgy","avatar_url":"https://avatars2.githubusercontent.com/u/11707082?v=4","gravatar_id":"","url":"https://api.github.com/users/asylvest","html_url":"https://github.com/asylvest","followers_url":"https://api.github.com/users/asylvest/followers","following_url":"https://api.github.com/users/asylvest/following{/other_user}","gists_url":"https://api.github.com/users/asylvest/gists{/gist_id}","starred_url":"https://api.github.com/users/asylvest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asylvest/subscriptions","organizations_url":"https://api.github.com/users/asylvest/orgs","repos_url":"https://api.github.com/users/asylvest/repos","events_url":"https://api.github.com/users/asylvest/events{/privacy}","received_events_url":"https://api.github.com/users/asylvest/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":2,"state":"open","created_at":"2018-09-04T16:03:16Z","updated_at":"2018-09-14T16:00:06Z","due_on":"2018-09-30T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/mdaus/coda-oss/pulls/267/commits","review_comments_url":"https://api.github.com/repos/mdaus/coda-oss/pulls/267/comments","review_comment_url":"https://api.github.com/repos/mdaus/coda-oss/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mdaus/coda-oss/issues/267/comments","statuses_url":"https://api.github.com/repos/mdaus/coda-oss/statuses/5a75b155fdf2e6d9b8fc7092eec97ecd9f59a456","head":{"label":"mdaus:scratchmemory","ref":"scratchmemory","sha":"5a75b155fdf2e6d9b8fc7092eec97ecd9f59a456","user":{"login":"mdaus","id":11707119,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzA3MTE5","avatar_url":"https://avatars3.githubusercontent.com/u/11707119?v=4","gravatar_id":"","url":"https://api.github.com/users/mdaus","html_url":"https://github.com/mdaus","followers_url":"https://api.github.com/users/mdaus/followers","following_url":"https://api.github.com/users/mdaus/following{/other_user}","gists_url":"https://api.github.com/users/mdaus/gists{/gist_id}","starred_url":"https://api.github.com/users/mdaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdaus/subscriptions","organizations_url":"https://api.github.com/users/mdaus/orgs","repos_url":"https://api.github.com/users/mdaus/repos","events_url":"https://api.github.com/users/mdaus/events{/privacy}","received_events_url":"https://api.github.com/users/mdaus/received_events","type":"Organization","site_admin":false},"repo":{"id":33076757,"node_id":"MDEwOlJlcG9zaXRvcnkzMzA3Njc1Nw==","name":"coda-oss","full_name":"mdaus/coda-oss","private":false,"owner":{"login":"mdaus","id":11707119,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzA3MTE5","avatar_url":"https://avatars3.githubusercontent.com/u/11707119?v=4","gravatar_id":"","url":"https://api.github.com/users/mdaus","html_url":"https://github.com/mdaus","followers_url":"https://api.github.com/users/mdaus/followers","following_url":"https://api.github.com/users/mdaus/following{/other_user}","gists_url":"https://api.github.com/users/mdaus/gists{/gist_id}","starred_url":"https://api.github.com/users/mdaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdaus/subscriptions","organizations_url":"https://api.github.com/users/mdaus/orgs","repos_url":"https://api.github.com/users/mdaus/repos","events_url":"https://api.github.com/users/mdaus/events{/privacy}","received_events_url":"https://api.github.com/users/mdaus/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mdaus/coda-oss","description":"The Common Open Development Archive (CODA-OSS) is a set of open source, modular components developed by MDA Information Systems LLC, primarily as a portable runtime for C++ processing.","fork":false,"url":"https://api.github.com/repos/mdaus/coda-oss","forks_url":"https://api.github.com/repos/mdaus/coda-oss/forks","keys_url":"https://api.github.com/repos/mdaus/coda-oss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdaus/coda-oss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdaus/coda-oss/teams","hooks_url":"https://api.github.com/repos/mdaus/coda-oss/hooks","issue_events_url":"https://api.github.com/repos/mdaus/coda-oss/issues/events{/number}","events_url":"https://api.github.com/repos/mdaus/coda-oss/events","assignees_url":"https://api.github.com/repos/mdaus/coda-oss/assignees{/user}","branches_url":"https://api.github.com/repos/mdaus/coda-oss/branches{/branch}","tags_url":"https://api.github.com/repos/mdaus/coda-oss/tags","blobs_url":"https://api.github.com/repos/mdaus/coda-oss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdaus/coda-oss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdaus/coda-oss/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdaus/coda-oss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdaus/coda-oss/statuses/{sha}","languages_url":"https://api.github.com/repos/mdaus/coda-oss/languages","stargazers_url":"https://api.github.com/repos/mdaus/coda-oss/stargazers","contributors_url":"https://api.github.com/repos/mdaus/coda-oss/contributors","subscribers_url":"https://api.github.com/repos/mdaus/coda-oss/subscribers","subscription_url":"https://api.github.com/repos/mdaus/coda-oss/subscription","commits_url":"https://api.github.com/repos/mdaus/coda-oss/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdaus/coda-oss/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdaus/coda-oss/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdaus/coda-oss/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdaus/coda-oss/contents/{+path}","compare_url":"https://api.github.com/repos/mdaus/coda-oss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdaus/coda-oss/merges","archive_url":"https://api.github.com/repos/mdaus/coda-oss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdaus/coda-oss/downloads","issues_url":"https://api.github.com/repos/mdaus/coda-oss/issues{/number}","pulls_url":"https://api.github.com/repos/mdaus/coda-oss/pulls{/number}","milestones_url":"https://api.github.com/repos/mdaus/coda-oss/milestones{/number}","notifications_url":"https://api.github.com/repos/mdaus/coda-oss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdaus/coda-oss/labels{/name}","releases_url":"https://api.github.com/repos/mdaus/coda-oss/releases{/id}","deployments_url":"https://api.github.com/repos/mdaus/coda-oss/deployments","created_at":"2015-03-29T14:48:12Z","updated_at":"2018-09-08T13:08:33Z","pushed_at":"2018-09-14T19:21:44Z","git_url":"git://github.com/mdaus/coda-oss.git","ssh_url":"git@github.com:mdaus/coda-oss.git","clone_url":"https://github.com/mdaus/coda-oss.git","svn_url":"https://github.com/mdaus/coda-oss","homepage":null,"size":30855,"stargazers_count":9,"watchers_count":9,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":7,"open_issues":24,"watchers":9,"default_branch":"master"}},"base":{"label":"mdaus:master","ref":"master","sha":"754a84038c37d38b5a824df5382b8886d648066b","user":{"login":"mdaus","id":11707119,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzA3MTE5","avatar_url":"https://avatars3.githubusercontent.com/u/11707119?v=4","gravatar_id":"","url":"https://api.github.com/users/mdaus","html_url":"https://github.com/mdaus","followers_url":"https://api.github.com/users/mdaus/followers","following_url":"https://api.github.com/users/mdaus/following{/other_user}","gists_url":"https://api.github.com/users/mdaus/gists{/gist_id}","starred_url":"https://api.github.com/users/mdaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdaus/subscriptions","organizations_url":"https://api.github.com/users/mdaus/orgs","repos_url":"https://api.github.com/users/mdaus/repos","events_url":"https://api.github.com/users/mdaus/events{/privacy}","received_events_url":"https://api.github.com/users/mdaus/received_events","type":"Organization","site_admin":false},"repo":{"id":33076757,"node_id":"MDEwOlJlcG9zaXRvcnkzMzA3Njc1Nw==","name":"coda-oss","full_name":"mdaus/coda-oss","private":false,"owner":{"login":"mdaus","id":11707119,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNzA3MTE5","avatar_url":"https://avatars3.githubusercontent.com/u/11707119?v=4","gravatar_id":"","url":"https://api.github.com/users/mdaus","html_url":"https://github.com/mdaus","followers_url":"https://api.github.com/users/mdaus/followers","following_url":"https://api.github.com/users/mdaus/following{/other_user}","gists_url":"https://api.github.com/users/mdaus/gists{/gist_id}","starred_url":"https://api.github.com/users/mdaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdaus/subscriptions","organizations_url":"https://api.github.com/users/mdaus/orgs","repos_url":"https://api.github.com/users/mdaus/repos","events_url":"https://api.github.com/users/mdaus/events{/privacy}","received_events_url":"https://api.github.com/users/mdaus/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/mdaus/coda-oss","description":"The Common Open Development Archive (CODA-OSS) is a set of open source, modular components developed by MDA Information Systems LLC, primarily as a portable runtime for C++ processing.","fork":false,"url":"https://api.github.com/repos/mdaus/coda-oss","forks_url":"https://api.github.com/repos/mdaus/coda-oss/forks","keys_url":"https://api.github.com/repos/mdaus/coda-oss/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mdaus/coda-oss/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mdaus/coda-oss/teams","hooks_url":"https://api.github.com/repos/mdaus/coda-oss/hooks","issue_events_url":"https://api.github.com/repos/mdaus/coda-oss/issues/events{/number}","events_url":"https://api.github.com/repos/mdaus/coda-oss/events","assignees_url":"https://api.github.com/repos/mdaus/coda-oss/assignees{/user}","branches_url":"https://api.github.com/repos/mdaus/coda-oss/branches{/branch}","tags_url":"https://api.github.com/repos/mdaus/coda-oss/tags","blobs_url":"https://api.github.com/repos/mdaus/coda-oss/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mdaus/coda-oss/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mdaus/coda-oss/git/refs{/sha}","trees_url":"https://api.github.com/repos/mdaus/coda-oss/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mdaus/coda-oss/statuses/{sha}","languages_url":"https://api.github.com/repos/mdaus/coda-oss/languages","stargazers_url":"https://api.github.com/repos/mdaus/coda-oss/stargazers","contributors_url":"https://api.github.com/repos/mdaus/coda-oss/contributors","subscribers_url":"https://api.github.com/repos/mdaus/coda-oss/subscribers","subscription_url":"https://api.github.com/repos/mdaus/coda-oss/subscription","commits_url":"https://api.github.com/repos/mdaus/coda-oss/commits{/sha}","git_commits_url":"https://api.github.com/repos/mdaus/coda-oss/git/commits{/sha}","comments_url":"https://api.github.com/repos/mdaus/coda-oss/comments{/number}","issue_comment_url":"https://api.github.com/repos/mdaus/coda-oss/issues/comments{/number}","contents_url":"https://api.github.com/repos/mdaus/coda-oss/contents/{+path}","compare_url":"https://api.github.com/repos/mdaus/coda-oss/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mdaus/coda-oss/merges","archive_url":"https://api.github.com/repos/mdaus/coda-oss/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mdaus/coda-oss/downloads","issues_url":"https://api.github.com/repos/mdaus/coda-oss/issues{/number}","pulls_url":"https://api.github.com/repos/mdaus/coda-oss/pulls{/number}","milestones_url":"https://api.github.com/repos/mdaus/coda-oss/milestones{/number}","notifications_url":"https://api.github.com/repos/mdaus/coda-oss/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mdaus/coda-oss/labels{/name}","releases_url":"https://api.github.com/repos/mdaus/coda-oss/releases{/id}","deployments_url":"https://api.github.com/repos/mdaus/coda-oss/deployments","created_at":"2015-03-29T14:48:12Z","updated_at":"2018-09-08T13:08:33Z","pushed_at":"2018-09-14T19:21:44Z","git_url":"git://github.com/mdaus/coda-oss.git","ssh_url":"git@github.com:mdaus/coda-oss.git","clone_url":"https://github.com/mdaus/coda-oss.git","svn_url":"https://github.com/mdaus/coda-oss","homepage":null,"size":30855,"stargazers_count":9,"watchers_count":9,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":7,"open_issues":24,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/267"},"html":{"href":"https://github.com/mdaus/coda-oss/pull/267"},"issue":{"href":"https://api.github.com/repos/mdaus/coda-oss/issues/267"},"comments":{"href":"https://api.github.com/repos/mdaus/coda-oss/issues/267/comments"},"review_comments":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/267/comments"},"review_comment":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mdaus/coda-oss/pulls/267/commits"},"statuses":{"href":"https://api.github.com/repos/mdaus/coda-oss/statuses/5a75b155fdf2e6d9b8fc7092eec97ecd9f59a456"}},"author_association":"NONE"}}
{"actor":{"display_login":"clydestanfield"}}