{"action":"created","comment":{"url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/comments/222962996","pull_request_review_id":161978527,"id":222962996,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMjk2Mjk5Ng==","diff_hunk":"@@ -0,0 +1,133 @@\n+#pragma once\n+#include <set>\n+#include <memory>\n+\n+using namespace std;\n+/*-----------------------------------------------------------------------------*/\n+/*\n+��������� � ���������� ������\n+*/\n+\n+template< typename T>\n+class my_list_alloc {\n+public:\n+\tusing value_type = T;\n+\n+\tusing reference = T&;\n+\tusing const_reference = const T&;\n+\n+\tusing pointer = T*;\n+\tusing const_pointer = const T*;\n+\n+\tvoid reserve(size_t n);\n+\t// Default constructor, copy constructor, rebinding constructor, and destructor.\n+\t// Empty for stateless allocators.\n+\tmy_list_alloc() = default;\n+\n+\tmy_list_alloc(const my_list_alloc&) = default;\n+\n+\ttemplate<typename U> my_list_alloc(const my_list_alloc<U>&) {};\n+\n+\t~my_list_alloc() = default;\n+\n+\tT* allocate(size_t n);\n+\tvoid deallocate(T* p, size_t n);\n+\n+\tvoid destroy(T* p) const {\n+\t\t//std::cout << \"destroy\" << std::endl;\n+\t\tp->~T();\n+\t}\n+\n+\ttemplate<class TT, class... Args>\n+\tvoid construct(TT* p, Args&&... args) {\n+\t\t//std::cout << \"construct\" << std::endl;\n+\t\tnew (p) TT(forward<Args>(args)...);\n+\t}\n+\n+\ttemplate<class U>\n+\tstruct rebind {\n+\t\tusing other = my_list_alloc<U>;\n+\t};\n+private:\n+\tset<void*> alloc_block;\n+\t\n+\tsize_t blockCount = 0;\n+\tbool has_initialized = false;\n+\tvoid* last_valid_address = nullptr;\n+\tvoid* managed_memory_start = nullptr;\n+};\n+\n+//template <class T, class U>\n+//bool operator==(const my_list_alloc<T>& t, const my_list_alloc<U>& u) {};\n+\n+//template <class T, class U>\n+//bool operator!=(const my_list_alloc<T>&, const my_list_alloc<U>&) {};\n+\n+\n+template<typename TT>\n+void my_list_alloc<TT>::reserve(size_t n)\n+{\n+\t// reserve() only one time.\n+\tif (has_initialized)\n+\t\treturn;\n+\n+\thas_initialized = true;\n+\tmanaged_memory_start = this->allocate(n);\n+\n+\tlast_valid_address = managed_memory_start;\n+\tblockCount = n;\n+}\n+\n+template<typename T>\n+inline T* my_list_alloc<T>::allocate(std::size_t n)\n+{\n+\tif (n == 0)\n+\t\treturn nullptr;\n+\n+\tT* endBuffer = (static_cast<T*>(managed_memory_start) + blockCount);\n+\tT* last_address = (static_cast<T*>(last_valid_address) + n);\n+\n+\tif (endBuffer >= last_address)\n+\t{\n+\t\t//std::cout << \"shift alloc: [n = \" << n << \"]\" << std::endl;\n+\t\tT* last_valid = static_cast<T*>(last_valid_address);\n+\t\tlast_valid_address = last_valid + n;\n+\t\t\n+\t\treturn static_cast<T* >(last_valid);\n+\t}\n+\telse\n+\t{\n+\t\t//std::cout << \"allocate: [n = \" << n << \"]\" << std::endl;\n+\t\tauto p = std::malloc(n * sizeof(T));\n+\t\tif (!p)\n+\t\t\tthrow std::bad_alloc();\n+\t\t\n+\t\talloc_block.insert(p);\n+\t\treturn static_cast<T* >(p);\n+\t}\n+\n+}\n+\n+template<typename T>\n+inline void my_list_alloc<T>::deallocate(T* p, size_t n)\n+{\n+\tif (p > managed_memory_start && p <= last_valid_address && has_initialized)\n+\t{\n+\t\t//std::cout << \"shift dealloc: [n  = \" << n << \"] \" << std::endl;\n+\t\treturn;","path":"my_alloc.cpp","position":117,"original_position":117,"commit_id":"d756919062d6c4f3ad8d002081e1c9c4d65ff6ee","original_commit_id":"d756919062d6c4f3ad8d002081e1c9c4d65ff6ee","user":{"login":"mkvdv","id":22629087,"node_id":"MDQ6VXNlcjIyNjI5MDg3","avatar_url":"https://avatars1.githubusercontent.com/u/22629087?v=4","gravatar_id":"","url":"https://api.github.com/users/mkvdv","html_url":"https://github.com/mkvdv","followers_url":"https://api.github.com/users/mkvdv/followers","following_url":"https://api.github.com/users/mkvdv/following{/other_user}","gists_url":"https://api.github.com/users/mkvdv/gists{/gist_id}","starred_url":"https://api.github.com/users/mkvdv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkvdv/subscriptions","organizations_url":"https://api.github.com/users/mkvdv/orgs","repos_url":"https://api.github.com/users/mkvdv/repos","events_url":"https://api.github.com/users/mkvdv/events{/privacy}","received_events_url":"https://api.github.com/users/mkvdv/received_events","type":"User","site_admin":false},"body":"> наш самописный аллокатор считает это кусок занятым, когда можно было бы его перезаписать новыми данными\r\n\r\nИменно. Получается аллокатор одноразовой памяти. Не то, что хотелось бы от аллокатора =)","created_at":"2018-10-05T10:37:28Z","updated_at":"2018-10-05T10:37:28Z","html_url":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2#discussion_r222962996","pull_request_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/comments/222962996"},"html":{"href":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2#discussion_r222962996"},"pull_request":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2"}},"in_reply_to_id":221432536},"pull_request":{"url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2","id":216015155,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2MDE1MTU1","html_url":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2","diff_url":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2.diff","patch_url":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2.patch","issue_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/2","number":2,"state":"open","locked":false,"title":"Review2. ДЗ-03 Allocator.","user":{"login":"AIGregor","id":16133002,"node_id":"MDQ6VXNlcjE2MTMzMDAy","avatar_url":"https://avatars0.githubusercontent.com/u/16133002?v=4","gravatar_id":"","url":"https://api.github.com/users/AIGregor","html_url":"https://github.com/AIGregor","followers_url":"https://api.github.com/users/AIGregor/followers","following_url":"https://api.github.com/users/AIGregor/following{/other_user}","gists_url":"https://api.github.com/users/AIGregor/gists{/gist_id}","starred_url":"https://api.github.com/users/AIGregor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIGregor/subscriptions","organizations_url":"https://api.github.com/users/AIGregor/orgs","repos_url":"https://api.github.com/users/AIGregor/repos","events_url":"https://api.github.com/users/AIGregor/events{/privacy}","received_events_url":"https://api.github.com/users/AIGregor/received_events","type":"User","site_admin":false},"body":"Create new review2 for task ДЗ-03 Allocator.","created_at":"2018-09-17T15:05:46Z","updated_at":"2018-10-05T10:37:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"98bad9d91c55f692ff871fc2004aa7c3f8a85689","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2/commits","review_comments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2/comments","review_comment_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/2/comments","statuses_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/statuses/d756919062d6c4f3ad8d002081e1c9c4d65ff6ee","head":{"label":"AIGregor:review2","ref":"review2","sha":"d756919062d6c4f3ad8d002081e1c9c4d65ff6ee","user":{"login":"AIGregor","id":16133002,"node_id":"MDQ6VXNlcjE2MTMzMDAy","avatar_url":"https://avatars0.githubusercontent.com/u/16133002?v=4","gravatar_id":"","url":"https://api.github.com/users/AIGregor","html_url":"https://github.com/AIGregor","followers_url":"https://api.github.com/users/AIGregor/followers","following_url":"https://api.github.com/users/AIGregor/following{/other_user}","gists_url":"https://api.github.com/users/AIGregor/gists{/gist_id}","starred_url":"https://api.github.com/users/AIGregor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIGregor/subscriptions","organizations_url":"https://api.github.com/users/AIGregor/orgs","repos_url":"https://api.github.com/users/AIGregor/repos","events_url":"https://api.github.com/users/AIGregor/events{/privacy}","received_events_url":"https://api.github.com/users/AIGregor/received_events","type":"User","site_admin":false},"repo":{"id":142570259,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI1NzAyNTk=","name":"OTUS-HW-ALLOC","full_name":"AIGregor/OTUS-HW-ALLOC","private":false,"owner":{"login":"AIGregor","id":16133002,"node_id":"MDQ6VXNlcjE2MTMzMDAy","avatar_url":"https://avatars0.githubusercontent.com/u/16133002?v=4","gravatar_id":"","url":"https://api.github.com/users/AIGregor","html_url":"https://github.com/AIGregor","followers_url":"https://api.github.com/users/AIGregor/followers","following_url":"https://api.github.com/users/AIGregor/following{/other_user}","gists_url":"https://api.github.com/users/AIGregor/gists{/gist_id}","starred_url":"https://api.github.com/users/AIGregor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIGregor/subscriptions","organizations_url":"https://api.github.com/users/AIGregor/orgs","repos_url":"https://api.github.com/users/AIGregor/repos","events_url":"https://api.github.com/users/AIGregor/events{/privacy}","received_events_url":"https://api.github.com/users/AIGregor/received_events","type":"User","site_admin":false},"html_url":"https://github.com/AIGregor/OTUS-HW-ALLOC","description":null,"fork":false,"url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC","forks_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/forks","keys_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/teams","hooks_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/hooks","issue_events_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/events{/number}","events_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/events","assignees_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/assignees{/user}","branches_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/branches{/branch}","tags_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/tags","blobs_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/refs{/sha}","trees_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/statuses/{sha}","languages_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/languages","stargazers_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/stargazers","contributors_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/contributors","subscribers_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/subscribers","subscription_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/subscription","commits_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/commits{/sha}","git_commits_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/commits{/sha}","comments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/comments{/number}","issue_comment_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/comments{/number}","contents_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/contents/{+path}","compare_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/merges","archive_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/downloads","issues_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues{/number}","pulls_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls{/number}","milestones_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/milestones{/number}","notifications_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/labels{/name}","releases_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/releases{/id}","deployments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/deployments","created_at":"2018-07-27T11:43:24Z","updated_at":"2018-09-17T14:52:40Z","pushed_at":"2018-09-17T15:05:47Z","git_url":"git://github.com/AIGregor/OTUS-HW-ALLOC.git","ssh_url":"git@github.com:AIGregor/OTUS-HW-ALLOC.git","clone_url":"https://github.com/AIGregor/OTUS-HW-ALLOC.git","svn_url":"https://github.com/AIGregor/OTUS-HW-ALLOC","homepage":null,"size":39,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"AIGregor:master","ref":"master","sha":"e505bb36898f2fd0b00811677b44454bf1a5ddd2","user":{"login":"AIGregor","id":16133002,"node_id":"MDQ6VXNlcjE2MTMzMDAy","avatar_url":"https://avatars0.githubusercontent.com/u/16133002?v=4","gravatar_id":"","url":"https://api.github.com/users/AIGregor","html_url":"https://github.com/AIGregor","followers_url":"https://api.github.com/users/AIGregor/followers","following_url":"https://api.github.com/users/AIGregor/following{/other_user}","gists_url":"https://api.github.com/users/AIGregor/gists{/gist_id}","starred_url":"https://api.github.com/users/AIGregor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIGregor/subscriptions","organizations_url":"https://api.github.com/users/AIGregor/orgs","repos_url":"https://api.github.com/users/AIGregor/repos","events_url":"https://api.github.com/users/AIGregor/events{/privacy}","received_events_url":"https://api.github.com/users/AIGregor/received_events","type":"User","site_admin":false},"repo":{"id":142570259,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI1NzAyNTk=","name":"OTUS-HW-ALLOC","full_name":"AIGregor/OTUS-HW-ALLOC","private":false,"owner":{"login":"AIGregor","id":16133002,"node_id":"MDQ6VXNlcjE2MTMzMDAy","avatar_url":"https://avatars0.githubusercontent.com/u/16133002?v=4","gravatar_id":"","url":"https://api.github.com/users/AIGregor","html_url":"https://github.com/AIGregor","followers_url":"https://api.github.com/users/AIGregor/followers","following_url":"https://api.github.com/users/AIGregor/following{/other_user}","gists_url":"https://api.github.com/users/AIGregor/gists{/gist_id}","starred_url":"https://api.github.com/users/AIGregor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AIGregor/subscriptions","organizations_url":"https://api.github.com/users/AIGregor/orgs","repos_url":"https://api.github.com/users/AIGregor/repos","events_url":"https://api.github.com/users/AIGregor/events{/privacy}","received_events_url":"https://api.github.com/users/AIGregor/received_events","type":"User","site_admin":false},"html_url":"https://github.com/AIGregor/OTUS-HW-ALLOC","description":null,"fork":false,"url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC","forks_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/forks","keys_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/teams","hooks_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/hooks","issue_events_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/events{/number}","events_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/events","assignees_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/assignees{/user}","branches_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/branches{/branch}","tags_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/tags","blobs_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/refs{/sha}","trees_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/statuses/{sha}","languages_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/languages","stargazers_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/stargazers","contributors_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/contributors","subscribers_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/subscribers","subscription_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/subscription","commits_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/commits{/sha}","git_commits_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/git/commits{/sha}","comments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/comments{/number}","issue_comment_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/comments{/number}","contents_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/contents/{+path}","compare_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/merges","archive_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/downloads","issues_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues{/number}","pulls_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls{/number}","milestones_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/milestones{/number}","notifications_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/labels{/name}","releases_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/releases{/id}","deployments_url":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/deployments","created_at":"2018-07-27T11:43:24Z","updated_at":"2018-09-17T14:52:40Z","pushed_at":"2018-09-17T15:05:47Z","git_url":"git://github.com/AIGregor/OTUS-HW-ALLOC.git","ssh_url":"git@github.com:AIGregor/OTUS-HW-ALLOC.git","clone_url":"https://github.com/AIGregor/OTUS-HW-ALLOC.git","svn_url":"https://github.com/AIGregor/OTUS-HW-ALLOC","homepage":null,"size":39,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2"},"html":{"href":"https://github.com/AIGregor/OTUS-HW-ALLOC/pull/2"},"issue":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/2"},"comments":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/AIGregor/OTUS-HW-ALLOC/statuses/d756919062d6c4f3ad8d002081e1c9c4d65ff6ee"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mkvdv"}}