{"action":"created","comment":{"url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments/215086645","pull_request_review_id":152276444,"id":215086645,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTA4NjY0NQ==","diff_hunk":"@@ -438,85 +473,103 @@ static inline bool aws_byte_cursor_read_be64(struct aws_byte_cursor *cur, uint64\n }\n \n /**\n- * Write specified number of bytes from array to byte cursor.\n+ * Write specified number of bytes from array to byte buffer.\n  *\n- * On success, returns true and updates the cursor pointer/length accordingly.\n- * If there is insufficient space in the cursor, returns false, leaving the\n- * cursor unchanged.\n+ * On success, returns true and updates the buffer length accordingly.\n+ * If there is insufficient space in the buffer, returns false, leaving the\n+ * buffer unchanged.\n  */\n-static inline bool aws_byte_cursor_write(\n-    struct aws_byte_cursor *AWS_RESTRICT cur,\n+static inline bool aws_byte_buf_write(\n+    struct aws_byte_buf *AWS_RESTRICT cur,\n     const uint8_t *AWS_RESTRICT src,\n     size_t len) {\n-    struct aws_byte_cursor slice = aws_byte_cursor_advance_nospec(cur, len);\n+\n+    struct aws_byte_cursor write_cursor;\n+    write_cursor.ptr = cur->buffer + cur->len;\n+    write_cursor.len = cur->capacity - cur->len;\n+    struct aws_byte_cursor slice = aws_byte_cursor_advance(&write_cursor, len);","path":"include/aws/common/byte_buf.h","position":145,"original_position":145,"commit_id":"01b527afc754cf5cf04e7d76d3b02978264010a1","original_commit_id":"01b527afc754cf5cf04e7d76d3b02978264010a1","user":{"login":"bdonlan","id":9473,"node_id":"MDQ6VXNlcjk0NzM=","avatar_url":"https://avatars1.githubusercontent.com/u/9473?v=4","gravatar_id":"","url":"https://api.github.com/users/bdonlan","html_url":"https://github.com/bdonlan","followers_url":"https://api.github.com/users/bdonlan/followers","following_url":"https://api.github.com/users/bdonlan/following{/other_user}","gists_url":"https://api.github.com/users/bdonlan/gists{/gist_id}","starred_url":"https://api.github.com/users/bdonlan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdonlan/subscriptions","organizations_url":"https://api.github.com/users/bdonlan/orgs","repos_url":"https://api.github.com/users/bdonlan/repos","events_url":"https://api.github.com/users/bdonlan/events{/privacy}","received_events_url":"https://api.github.com/users/bdonlan/received_events","type":"User","site_admin":false},"body":"Why are we doing this dance with cursors here?","created_at":"2018-09-04T22:29:31Z","updated_at":"2018-09-04T22:32:17Z","html_url":"https://github.com/awslabs/aws-c-common/pull/130#discussion_r215086645","pull_request_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments/215086645"},"html":{"href":"https://github.com/awslabs/aws-c-common/pull/130#discussion_r215086645"},"pull_request":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130"}}},"pull_request":{"url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130","id":210853393,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwODUzMzkz","html_url":"https://github.com/awslabs/aws-c-common/pull/130","diff_url":"https://github.com/awslabs/aws-c-common/pull/130.diff","patch_url":"https://github.com/awslabs/aws-c-common/pull/130.patch","issue_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/130","number":130,"state":"open","locked":false,"title":"Convert writing methods to write to aws_byte_buf","user":{"login":"ColdenCullen","id":1354824,"node_id":"MDQ6VXNlcjEzNTQ4MjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1354824?v=4","gravatar_id":"","url":"https://api.github.com/users/ColdenCullen","html_url":"https://github.com/ColdenCullen","followers_url":"https://api.github.com/users/ColdenCullen/followers","following_url":"https://api.github.com/users/ColdenCullen/following{/other_user}","gists_url":"https://api.github.com/users/ColdenCullen/gists{/gist_id}","starred_url":"https://api.github.com/users/ColdenCullen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ColdenCullen/subscriptions","organizations_url":"https://api.github.com/users/ColdenCullen/orgs","repos_url":"https://api.github.com/users/ColdenCullen/repos","events_url":"https://api.github.com/users/ColdenCullen/events{/privacy}","received_events_url":"https://api.github.com/users/ColdenCullen/received_events","type":"User","site_admin":false},"body":"With this PR, contracts become much more clear. `aws_byte_cursor` is used for reading from, and `aws_byte_buf` is used for writing to. Users are still free to manage their memory with `aws_byte_buf` however, they just need to create a cursor for it before reading from it. Practice shows this doesn't actually happen a whole lot.\r\n\r\nExample usage changes can be seen here, in the [IO](https://github.com/awslabs/aws-c-io/compare/tls-s2n...tls-s2n-write-buffer?expand=1) and [MQTT](https://github.com/awslabs/aws-c-mqtt/compare/write-buffer?expand=1) repos.\r\n\r\nBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.","created_at":"2018-08-24T21:29:45Z","updated_at":"2018-09-04T22:32:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59e1d9b8508c52d59672fbf1b46241b515f115e8","assignee":null,"assignees":[],"requested_reviewers":[{"login":"JonathanHenson","id":3926469,"node_id":"MDQ6VXNlcjM5MjY0Njk=","avatar_url":"https://avatars2.githubusercontent.com/u/3926469?v=4","gravatar_id":"","url":"https://api.github.com/users/JonathanHenson","html_url":"https://github.com/JonathanHenson","followers_url":"https://api.github.com/users/JonathanHenson/followers","following_url":"https://api.github.com/users/JonathanHenson/following{/other_user}","gists_url":"https://api.github.com/users/JonathanHenson/gists{/gist_id}","starred_url":"https://api.github.com/users/JonathanHenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JonathanHenson/subscriptions","organizations_url":"https://api.github.com/users/JonathanHenson/orgs","repos_url":"https://api.github.com/users/JonathanHenson/repos","events_url":"https://api.github.com/users/JonathanHenson/events{/privacy}","received_events_url":"https://api.github.com/users/JonathanHenson/received_events","type":"User","site_admin":false},{"login":"david-koenig","id":36861050,"node_id":"MDQ6VXNlcjM2ODYxMDUw","avatar_url":"https://avatars0.githubusercontent.com/u/36861050?v=4","gravatar_id":"","url":"https://api.github.com/users/david-koenig","html_url":"https://github.com/david-koenig","followers_url":"https://api.github.com/users/david-koenig/followers","following_url":"https://api.github.com/users/david-koenig/following{/other_user}","gists_url":"https://api.github.com/users/david-koenig/gists{/gist_id}","starred_url":"https://api.github.com/users/david-koenig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-koenig/subscriptions","organizations_url":"https://api.github.com/users/david-koenig/orgs","repos_url":"https://api.github.com/users/david-koenig/repos","events_url":"https://api.github.com/users/david-koenig/events{/privacy}","received_events_url":"https://api.github.com/users/david-koenig/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130/commits","review_comments_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130/comments","review_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/130/comments","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/01b527afc754cf5cf04e7d76d3b02978264010a1","head":{"label":"awslabs:write-buffer","ref":"write-buffer","sha":"01b527afc754cf5cf04e7d76d3b02978264010a1","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":117142517,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcxNDI1MTc=","name":"aws-c-common","full_name":"awslabs/aws-c-common","owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-c-common","description":"Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.","fork":false,"url":"https://api.github.com/repos/awslabs/aws-c-common","forks_url":"https://api.github.com/repos/awslabs/aws-c-common/forks","keys_url":"https://api.github.com/repos/awslabs/aws-c-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-c-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-c-common/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-c-common/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-c-common/events","assignees_url":"https://api.github.com/repos/awslabs/aws-c-common/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-c-common/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-c-common/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-c-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-c-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-c-common/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-c-common/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-c-common/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-c-common/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-c-common/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-c-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-c-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-c-common/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-c-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-c-common/merges","archive_url":"https://api.github.com/repos/awslabs/aws-c-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-c-common/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-c-common/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-c-common/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-c-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-c-common/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-c-common/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-c-common/deployments","created_at":"2018-01-11T19:17:12Z","updated_at":"2018-09-04T21:19:42Z","pushed_at":"2018-09-04T22:21:48Z","git_url":"git://github.com/awslabs/aws-c-common.git","ssh_url":"git@github.com:awslabs/aws-c-common.git","clone_url":"https://github.com/awslabs/aws-c-common.git","svn_url":"https://github.com/awslabs/aws-c-common","homepage":null,"size":710,"stargazers_count":28,"watchers_count":28,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":12,"open_issues":10,"watchers":28,"default_branch":"master"}},"base":{"label":"awslabs:master","ref":"master","sha":"1bb42dc004590e26af8f8ce111ce72f708838d9a","user":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"repo":{"id":117142517,"node_id":"MDEwOlJlcG9zaXRvcnkxMTcxNDI1MTc=","name":"aws-c-common","full_name":"awslabs/aws-c-common","owner":{"login":"awslabs","id":3299148,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyOTkxNDg=","avatar_url":"https://avatars0.githubusercontent.com/u/3299148?v=4","gravatar_id":"","url":"https://api.github.com/users/awslabs","html_url":"https://github.com/awslabs","followers_url":"https://api.github.com/users/awslabs/followers","following_url":"https://api.github.com/users/awslabs/following{/other_user}","gists_url":"https://api.github.com/users/awslabs/gists{/gist_id}","starred_url":"https://api.github.com/users/awslabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awslabs/subscriptions","organizations_url":"https://api.github.com/users/awslabs/orgs","repos_url":"https://api.github.com/users/awslabs/repos","events_url":"https://api.github.com/users/awslabs/events{/privacy}","received_events_url":"https://api.github.com/users/awslabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awslabs/aws-c-common","description":"Core c99 package for AWS SDK for C. Includes cross-platform primitives, configuration, data structures, and error handling.","fork":false,"url":"https://api.github.com/repos/awslabs/aws-c-common","forks_url":"https://api.github.com/repos/awslabs/aws-c-common/forks","keys_url":"https://api.github.com/repos/awslabs/aws-c-common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awslabs/aws-c-common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awslabs/aws-c-common/teams","hooks_url":"https://api.github.com/repos/awslabs/aws-c-common/hooks","issue_events_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/events{/number}","events_url":"https://api.github.com/repos/awslabs/aws-c-common/events","assignees_url":"https://api.github.com/repos/awslabs/aws-c-common/assignees{/user}","branches_url":"https://api.github.com/repos/awslabs/aws-c-common/branches{/branch}","tags_url":"https://api.github.com/repos/awslabs/aws-c-common/tags","blobs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awslabs/aws-c-common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awslabs/aws-c-common/git/refs{/sha}","trees_url":"https://api.github.com/repos/awslabs/aws-c-common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awslabs/aws-c-common/statuses/{sha}","languages_url":"https://api.github.com/repos/awslabs/aws-c-common/languages","stargazers_url":"https://api.github.com/repos/awslabs/aws-c-common/stargazers","contributors_url":"https://api.github.com/repos/awslabs/aws-c-common/contributors","subscribers_url":"https://api.github.com/repos/awslabs/aws-c-common/subscribers","subscription_url":"https://api.github.com/repos/awslabs/aws-c-common/subscription","commits_url":"https://api.github.com/repos/awslabs/aws-c-common/commits{/sha}","git_commits_url":"https://api.github.com/repos/awslabs/aws-c-common/git/commits{/sha}","comments_url":"https://api.github.com/repos/awslabs/aws-c-common/comments{/number}","issue_comment_url":"https://api.github.com/repos/awslabs/aws-c-common/issues/comments{/number}","contents_url":"https://api.github.com/repos/awslabs/aws-c-common/contents/{+path}","compare_url":"https://api.github.com/repos/awslabs/aws-c-common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awslabs/aws-c-common/merges","archive_url":"https://api.github.com/repos/awslabs/aws-c-common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awslabs/aws-c-common/downloads","issues_url":"https://api.github.com/repos/awslabs/aws-c-common/issues{/number}","pulls_url":"https://api.github.com/repos/awslabs/aws-c-common/pulls{/number}","milestones_url":"https://api.github.com/repos/awslabs/aws-c-common/milestones{/number}","notifications_url":"https://api.github.com/repos/awslabs/aws-c-common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awslabs/aws-c-common/labels{/name}","releases_url":"https://api.github.com/repos/awslabs/aws-c-common/releases{/id}","deployments_url":"https://api.github.com/repos/awslabs/aws-c-common/deployments","created_at":"2018-01-11T19:17:12Z","updated_at":"2018-09-04T21:19:42Z","pushed_at":"2018-09-04T22:21:48Z","git_url":"git://github.com/awslabs/aws-c-common.git","ssh_url":"git@github.com:awslabs/aws-c-common.git","clone_url":"https://github.com/awslabs/aws-c-common.git","svn_url":"https://github.com/awslabs/aws-c-common","homepage":null,"size":710,"stargazers_count":28,"watchers_count":28,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":12,"open_issues":10,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130"},"html":{"href":"https://github.com/awslabs/aws-c-common/pull/130"},"issue":{"href":"https://api.github.com/repos/awslabs/aws-c-common/issues/130"},"comments":{"href":"https://api.github.com/repos/awslabs/aws-c-common/issues/130/comments"},"review_comments":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130/comments"},"review_comment":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awslabs/aws-c-common/pulls/130/commits"},"statuses":{"href":"https://api.github.com/repos/awslabs/aws-c-common/statuses/01b527afc754cf5cf04e7d76d3b02978264010a1"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"bdonlan"}}