{"action":"created","comment":{"url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments/227437910","pull_request_review_id":167477682,"id":227437910,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNzQzNzkxMA==","diff_hunk":"@@ -83,29 +83,43 @@ size_t secp256k1_context_prealloc_size(unsigned int flags) {\n     return ret;\n }\n \n-secp256k1_context* secp256k1_context_create(unsigned int flags) {\n-    secp256k1_context* ret = (secp256k1_context*)checked_malloc(&default_error_callback, sizeof(secp256k1_context));\n+secp256k1_context* secp256k1_context_prealloc_create(void* prealloc, unsigned int flags) {\n+    void* const base = prealloc;\n+    size_t const ctx_size = secp256k1_context_prealloc_size(flags);\n+    secp256k1_context* ret = (secp256k1_context*)manual_alloc(&prealloc, sizeof(secp256k1_context), base, ctx_size);\n+\n     ret->illegal_callback = default_illegal_callback;\n     ret->error_callback = default_error_callback;\n \n     if (EXPECT((flags & SECP256K1_FLAGS_TYPE_MASK) != SECP256K1_FLAGS_TYPE_CONTEXT, 0)) {\n             secp256k1_callback_call(&ret->illegal_callback,\n                                     \"Invalid flags\");\n-            free(ret);\n+            /* Unreachable */","path":"src/secp256k1.c","position":45,"original_position":18,"commit_id":"f24aa9cb95629ec1030af3b72b0ff6a3fd0b8997","original_commit_id":"f24aa9cb95629ec1030af3b72b0ff6a3fd0b8997","user":{"login":"apoelstra","id":1351933,"node_id":"MDQ6VXNlcjEzNTE5MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1351933?v=4","gravatar_id":"","url":"https://api.github.com/users/apoelstra","html_url":"https://github.com/apoelstra","followers_url":"https://api.github.com/users/apoelstra/followers","following_url":"https://api.github.com/users/apoelstra/following{/other_user}","gists_url":"https://api.github.com/users/apoelstra/gists{/gist_id}","starred_url":"https://api.github.com/users/apoelstra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apoelstra/subscriptions","organizations_url":"https://api.github.com/users/apoelstra/orgs","repos_url":"https://api.github.com/users/apoelstra/repos","events_url":"https://api.github.com/users/apoelstra/events{/privacy}","received_events_url":"https://api.github.com/users/apoelstra/received_events","type":"User","site_admin":false},"body":"Oh, yeah, you're right.","created_at":"2018-10-23T15:09:29Z","updated_at":"2018-10-23T15:09:29Z","html_url":"https://github.com/bitcoin-core/secp256k1/pull/566#discussion_r227437910","pull_request_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments/227437910"},"html":{"href":"https://github.com/bitcoin-core/secp256k1/pull/566#discussion_r227437910"},"pull_request":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566"}},"in_reply_to_id":227071784},"pull_request":{"url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566","id":224715914,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0NzE1OTE0","html_url":"https://github.com/bitcoin-core/secp256k1/pull/566","diff_url":"https://github.com/bitcoin-core/secp256k1/pull/566.diff","patch_url":"https://github.com/bitcoin-core/secp256k1/pull/566.patch","issue_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/566","number":566,"state":"open","locked":false,"title":"WIP: Enable context creation with preallocated memory blob","user":{"login":"real-or-random","id":1071625,"node_id":"MDQ6VXNlcjEwNzE2MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1071625?v=4","gravatar_id":"","url":"https://api.github.com/users/real-or-random","html_url":"https://github.com/real-or-random","followers_url":"https://api.github.com/users/real-or-random/followers","following_url":"https://api.github.com/users/real-or-random/following{/other_user}","gists_url":"https://api.github.com/users/real-or-random/gists{/gist_id}","starred_url":"https://api.github.com/users/real-or-random/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/real-or-random/subscriptions","organizations_url":"https://api.github.com/users/real-or-random/orgs","repos_url":"https://api.github.com/users/real-or-random/repos","events_url":"https://api.github.com/users/real-or-random/events{/privacy}","received_events_url":"https://api.github.com/users/real-or-random/received_events","type":"User","site_admin":false},"body":"@apoelstra \r\n\r\nThis builds on #557.\r\n\r\nManually managing memory is always a pain in the ass in some way. I tried to keep the pain manageable. I'm open to suggestions to make this less ugly or error-prone.\r\n\r\nto do:\r\n * tests\r\n * export functions","created_at":"2018-10-22T15:21:11Z","updated_at":"2018-10-23T15:09:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8caad054cb22b9c3b01109a8bf176c40656d1bd7","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566/commits","review_comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566/comments","review_comment_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/566/comments","statuses_url":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/f24aa9cb95629ec1030af3b72b0ff6a3fd0b8997","head":{"label":"real-or-random:no-alloc","ref":"no-alloc","sha":"f24aa9cb95629ec1030af3b72b0ff6a3fd0b8997","user":{"login":"real-or-random","id":1071625,"node_id":"MDQ6VXNlcjEwNzE2MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1071625?v=4","gravatar_id":"","url":"https://api.github.com/users/real-or-random","html_url":"https://github.com/real-or-random","followers_url":"https://api.github.com/users/real-or-random/followers","following_url":"https://api.github.com/users/real-or-random/following{/other_user}","gists_url":"https://api.github.com/users/real-or-random/gists{/gist_id}","starred_url":"https://api.github.com/users/real-or-random/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/real-or-random/subscriptions","organizations_url":"https://api.github.com/users/real-or-random/orgs","repos_url":"https://api.github.com/users/real-or-random/repos","events_url":"https://api.github.com/users/real-or-random/events{/privacy}","received_events_url":"https://api.github.com/users/real-or-random/received_events","type":"User","site_admin":false},"repo":{"id":93596674,"node_id":"MDEwOlJlcG9zaXRvcnk5MzU5NjY3NA==","name":"secp256k1","full_name":"real-or-random/secp256k1","private":false,"owner":{"login":"real-or-random","id":1071625,"node_id":"MDQ6VXNlcjEwNzE2MjU=","avatar_url":"https://avatars1.githubusercontent.com/u/1071625?v=4","gravatar_id":"","url":"https://api.github.com/users/real-or-random","html_url":"https://github.com/real-or-random","followers_url":"https://api.github.com/users/real-or-random/followers","following_url":"https://api.github.com/users/real-or-random/following{/other_user}","gists_url":"https://api.github.com/users/real-or-random/gists{/gist_id}","starred_url":"https://api.github.com/users/real-or-random/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/real-or-random/subscriptions","organizations_url":"https://api.github.com/users/real-or-random/orgs","repos_url":"https://api.github.com/users/real-or-random/repos","events_url":"https://api.github.com/users/real-or-random/events{/privacy}","received_events_url":"https://api.github.com/users/real-or-random/received_events","type":"User","site_admin":false},"html_url":"https://github.com/real-or-random/secp256k1","description":"Optimized C library for EC operations on curve secp256k1","fork":true,"url":"https://api.github.com/repos/real-or-random/secp256k1","forks_url":"https://api.github.com/repos/real-or-random/secp256k1/forks","keys_url":"https://api.github.com/repos/real-or-random/secp256k1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/real-or-random/secp256k1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/real-or-random/secp256k1/teams","hooks_url":"https://api.github.com/repos/real-or-random/secp256k1/hooks","issue_events_url":"https://api.github.com/repos/real-or-random/secp256k1/issues/events{/number}","events_url":"https://api.github.com/repos/real-or-random/secp256k1/events","assignees_url":"https://api.github.com/repos/real-or-random/secp256k1/assignees{/user}","branches_url":"https://api.github.com/repos/real-or-random/secp256k1/branches{/branch}","tags_url":"https://api.github.com/repos/real-or-random/secp256k1/tags","blobs_url":"https://api.github.com/repos/real-or-random/secp256k1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/real-or-random/secp256k1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/real-or-random/secp256k1/git/refs{/sha}","trees_url":"https://api.github.com/repos/real-or-random/secp256k1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/real-or-random/secp256k1/statuses/{sha}","languages_url":"https://api.github.com/repos/real-or-random/secp256k1/languages","stargazers_url":"https://api.github.com/repos/real-or-random/secp256k1/stargazers","contributors_url":"https://api.github.com/repos/real-or-random/secp256k1/contributors","subscribers_url":"https://api.github.com/repos/real-or-random/secp256k1/subscribers","subscription_url":"https://api.github.com/repos/real-or-random/secp256k1/subscription","commits_url":"https://api.github.com/repos/real-or-random/secp256k1/commits{/sha}","git_commits_url":"https://api.github.com/repos/real-or-random/secp256k1/git/commits{/sha}","comments_url":"https://api.github.com/repos/real-or-random/secp256k1/comments{/number}","issue_comment_url":"https://api.github.com/repos/real-or-random/secp256k1/issues/comments{/number}","contents_url":"https://api.github.com/repos/real-or-random/secp256k1/contents/{+path}","compare_url":"https://api.github.com/repos/real-or-random/secp256k1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/real-or-random/secp256k1/merges","archive_url":"https://api.github.com/repos/real-or-random/secp256k1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/real-or-random/secp256k1/downloads","issues_url":"https://api.github.com/repos/real-or-random/secp256k1/issues{/number}","pulls_url":"https://api.github.com/repos/real-or-random/secp256k1/pulls{/number}","milestones_url":"https://api.github.com/repos/real-or-random/secp256k1/milestones{/number}","notifications_url":"https://api.github.com/repos/real-or-random/secp256k1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/real-or-random/secp256k1/labels{/name}","releases_url":"https://api.github.com/repos/real-or-random/secp256k1/releases{/id}","deployments_url":"https://api.github.com/repos/real-or-random/secp256k1/deployments","created_at":"2017-06-07T05:39:43Z","updated_at":"2017-06-07T05:39:45Z","pushed_at":"2018-10-22T15:24:27Z","git_url":"git://github.com/real-or-random/secp256k1.git","ssh_url":"git@github.com:real-or-random/secp256k1.git","clone_url":"https://github.com/real-or-random/secp256k1.git","svn_url":"https://github.com/real-or-random/secp256k1","homepage":null,"size":1824,"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":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bitcoin-core:master","ref":"master","sha":"1086fda4c1975d0cad8d3cad96794a64ec12dca4","user":{"login":"bitcoin-core","id":13464320,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDY0MzIw","avatar_url":"https://avatars2.githubusercontent.com/u/13464320?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin-core","html_url":"https://github.com/bitcoin-core","followers_url":"https://api.github.com/users/bitcoin-core/followers","following_url":"https://api.github.com/users/bitcoin-core/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin-core/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin-core/subscriptions","organizations_url":"https://api.github.com/users/bitcoin-core/orgs","repos_url":"https://api.github.com/users/bitcoin-core/repos","events_url":"https://api.github.com/users/bitcoin-core/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin-core/received_events","type":"Organization","site_admin":false},"repo":{"id":16648618,"node_id":"MDEwOlJlcG9zaXRvcnkxNjY0ODYxOA==","name":"secp256k1","full_name":"bitcoin-core/secp256k1","private":false,"owner":{"login":"bitcoin-core","id":13464320,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDY0MzIw","avatar_url":"https://avatars2.githubusercontent.com/u/13464320?v=4","gravatar_id":"","url":"https://api.github.com/users/bitcoin-core","html_url":"https://github.com/bitcoin-core","followers_url":"https://api.github.com/users/bitcoin-core/followers","following_url":"https://api.github.com/users/bitcoin-core/following{/other_user}","gists_url":"https://api.github.com/users/bitcoin-core/gists{/gist_id}","starred_url":"https://api.github.com/users/bitcoin-core/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bitcoin-core/subscriptions","organizations_url":"https://api.github.com/users/bitcoin-core/orgs","repos_url":"https://api.github.com/users/bitcoin-core/repos","events_url":"https://api.github.com/users/bitcoin-core/events{/privacy}","received_events_url":"https://api.github.com/users/bitcoin-core/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bitcoin-core/secp256k1","description":"Optimized C library for EC operations on curve secp256k1","fork":false,"url":"https://api.github.com/repos/bitcoin-core/secp256k1","forks_url":"https://api.github.com/repos/bitcoin-core/secp256k1/forks","keys_url":"https://api.github.com/repos/bitcoin-core/secp256k1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bitcoin-core/secp256k1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bitcoin-core/secp256k1/teams","hooks_url":"https://api.github.com/repos/bitcoin-core/secp256k1/hooks","issue_events_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/events{/number}","events_url":"https://api.github.com/repos/bitcoin-core/secp256k1/events","assignees_url":"https://api.github.com/repos/bitcoin-core/secp256k1/assignees{/user}","branches_url":"https://api.github.com/repos/bitcoin-core/secp256k1/branches{/branch}","tags_url":"https://api.github.com/repos/bitcoin-core/secp256k1/tags","blobs_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/refs{/sha}","trees_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/{sha}","languages_url":"https://api.github.com/repos/bitcoin-core/secp256k1/languages","stargazers_url":"https://api.github.com/repos/bitcoin-core/secp256k1/stargazers","contributors_url":"https://api.github.com/repos/bitcoin-core/secp256k1/contributors","subscribers_url":"https://api.github.com/repos/bitcoin-core/secp256k1/subscribers","subscription_url":"https://api.github.com/repos/bitcoin-core/secp256k1/subscription","commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/commits{/sha}","git_commits_url":"https://api.github.com/repos/bitcoin-core/secp256k1/git/commits{/sha}","comments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/comments{/number}","issue_comment_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/comments{/number}","contents_url":"https://api.github.com/repos/bitcoin-core/secp256k1/contents/{+path}","compare_url":"https://api.github.com/repos/bitcoin-core/secp256k1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bitcoin-core/secp256k1/merges","archive_url":"https://api.github.com/repos/bitcoin-core/secp256k1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bitcoin-core/secp256k1/downloads","issues_url":"https://api.github.com/repos/bitcoin-core/secp256k1/issues{/number}","pulls_url":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls{/number}","milestones_url":"https://api.github.com/repos/bitcoin-core/secp256k1/milestones{/number}","notifications_url":"https://api.github.com/repos/bitcoin-core/secp256k1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bitcoin-core/secp256k1/labels{/name}","releases_url":"https://api.github.com/repos/bitcoin-core/secp256k1/releases{/id}","deployments_url":"https://api.github.com/repos/bitcoin-core/secp256k1/deployments","created_at":"2014-02-08T17:30:06Z","updated_at":"2018-10-21T16:52:44Z","pushed_at":"2018-10-23T00:28:14Z","git_url":"git://github.com/bitcoin-core/secp256k1.git","ssh_url":"git@github.com:bitcoin-core/secp256k1.git","clone_url":"https://github.com/bitcoin-core/secp256k1.git","svn_url":"https://github.com/bitcoin-core/secp256k1","homepage":null,"size":1792,"stargazers_count":664,"watchers_count":664,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":425,"mirror_url":null,"archived":false,"open_issues_count":105,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":425,"open_issues":105,"watchers":664,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566"},"html":{"href":"https://github.com/bitcoin-core/secp256k1/pull/566"},"issue":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/566"},"comments":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/issues/566/comments"},"review_comments":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566/comments"},"review_comment":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/pulls/566/commits"},"statuses":{"href":"https://api.github.com/repos/bitcoin-core/secp256k1/statuses/f24aa9cb95629ec1030af3b72b0ff6a3fd0b8997"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"apoelstra"}}