{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/comments/181748444","pull_request_review_id":112413724,"id":181748444,"diff_hunk":"@@ -86,59 +88,86 @@ char* php_phongo_field_path_as_string(php_phongo_field_path* field_path)\n \treturn path;\n }\n \n-php_phongo_field_path* php_phongo_field_path_alloc(void)\n+php_phongo_field_path* php_phongo_field_path_alloc(bool free_elements)\n {\n \tphp_phongo_field_path* tmp = ecalloc(1, sizeof(php_phongo_field_path));\n \ttmp->ref_count             = 1;\n+\ttmp->free_elements         = free_elements;\n \n \treturn tmp;\n }\n \n void php_phongo_field_path_free(php_phongo_field_path* field_path)\n {\n+\tif (field_path->free_elements) {\n+\t\tsize_t i;\n+\n+\t\tfor (i = 0; i < field_path->size; i++) {\n+\t\t\tefree(field_path->elements[i]);\n+\t\t}\n+\t}\n \tif (field_path->elements) {\n \t\tefree(field_path->elements);\n \t}\n+\tif (field_path->element_types) {\n+\t\tefree(field_path->element_types);\n+\t}\n \tefree(field_path);\n }\n \n static void php_phongo_field_path_ensure_allocation(php_phongo_field_path* field_path, size_t level)\n {\n-\tif (level >= field_path->allocated_levels) {\n+\tif (level >= field_path->allocated) {\n \t\tsize_t i;\n \n-\t\tfield_path->allocated_levels = field_path->current_level + PHONGO_FIELD_PATH_EXPANSION;\n-\t\tfield_path->elements         = erealloc(field_path->elements, sizeof(char**) * field_path->allocated_levels);\n+\t\tfield_path->allocated     = field_path->size + PHONGO_FIELD_PATH_EXPANSION;\n+\t\tfield_path->elements      = erealloc(field_path->elements, sizeof(char**) * field_path->allocated);\n+\t\tfield_path->element_types = erealloc(field_path->element_types, sizeof(php_phongo_bson_field_path_item_types*) * field_path->allocated);\n \n-\t\tfor (i = level; i < field_path->allocated_levels; i++) {\n-\t\t\tfield_path->elements[i] = NULL;\n+\t\tfor (i = level; i < field_path->allocated; i++) {\n+\t\t\tfield_path->elements[i]      = NULL;\n+\t\t\tfield_path->element_types[i] = PHONGO_FIELD_PATH_ITEM_NONE;\n \t\t}\n \t}\n }\n \n void php_phongo_field_path_write_item_at_current_level(php_phongo_field_path* field_path, const char* element)\n {\n-\tphp_phongo_field_path_ensure_allocation(field_path, field_path->current_level);\n+\tphp_phongo_field_path_ensure_allocation(field_path, field_path->size);\n+\n+\tif (field_path->free_elements) {","path":"src/bson.c","position":85,"original_position":85,"commit_id":"67328be7c32866b5ecf1636e1585ec4ac43e1a65","original_commit_id":"67328be7c32866b5ecf1636e1585ec4ac43e1a65","user":{"login":"jmikola","id":244663,"avatar_url":"https://avatars3.githubusercontent.com/u/244663?v=4","gravatar_id":"","url":"https://api.github.com/users/jmikola","html_url":"https://github.com/jmikola","followers_url":"https://api.github.com/users/jmikola/followers","following_url":"https://api.github.com/users/jmikola/following{/other_user}","gists_url":"https://api.github.com/users/jmikola/gists{/gist_id}","starred_url":"https://api.github.com/users/jmikola/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmikola/subscriptions","organizations_url":"https://api.github.com/users/jmikola/orgs","repos_url":"https://api.github.com/users/jmikola/repos","events_url":"https://api.github.com/users/jmikola/events{/privacy}","received_events_url":"https://api.github.com/users/jmikola/received_events","type":"User","site_admin":false},"body":"If `free_elements` isn't just used for free logic, I might suggest calling it `copy_elements` instead. That makes it clearer that this function is doing to `estrdup()` and likewise makes sense when you check it to free each element later on.\r\n\r\nAs-is, I would expect the caller to do `estrdup()` on its own.","created_at":"2018-04-16T14:14:27Z","updated_at":"2018-04-16T14:35:34Z","html_url":"https://github.com/mongodb/mongo-php-driver/pull/793#discussion_r181748444","pull_request_url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/comments/181748444"},"html":{"href":"https://github.com/mongodb/mongo-php-driver/pull/793#discussion_r181748444"},"pull_request":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793"}}},"pull_request":{"url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793","id":179432667,"html_url":"https://github.com/mongodb/mongo-php-driver/pull/793","diff_url":"https://github.com/mongodb/mongo-php-driver/pull/793.diff","patch_url":"https://github.com/mongodb/mongo-php-driver/pull/793.patch","issue_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/793","number":793,"state":"open","locked":false,"title":"PHPC-314: Implement type map syntax for documents within field paths","user":{"login":"derickr","id":208074,"avatar_url":"https://avatars3.githubusercontent.com/u/208074?v=4","gravatar_id":"","url":"https://api.github.com/users/derickr","html_url":"https://github.com/derickr","followers_url":"https://api.github.com/users/derickr/followers","following_url":"https://api.github.com/users/derickr/following{/other_user}","gists_url":"https://api.github.com/users/derickr/gists{/gist_id}","starred_url":"https://api.github.com/users/derickr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derickr/subscriptions","organizations_url":"https://api.github.com/users/derickr/orgs","repos_url":"https://api.github.com/users/derickr/repos","events_url":"https://api.github.com/users/derickr/events{/privacy}","received_events_url":"https://api.github.com/users/derickr/received_events","type":"User","site_admin":false},"body":"First step of implementing the fieldPath syntax. It doesn't do wild cards yet, or typemaps for scalar types.","created_at":"2018-04-04T15:42:50Z","updated_at":"2018-04-16T14:35:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0043c9c1087f1e2bdf1bbba2829ff7e9ae73f93d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793/commits","review_comments_url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793/comments","review_comment_url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/793/comments","statuses_url":"https://api.github.com/repos/mongodb/mongo-php-driver/statuses/67328be7c32866b5ecf1636e1585ec4ac43e1a65","head":{"label":"derickr:PHPC-314-typemap-for-fieldpaths","ref":"PHPC-314-typemap-for-fieldpaths","sha":"67328be7c32866b5ecf1636e1585ec4ac43e1a65","user":{"login":"derickr","id":208074,"avatar_url":"https://avatars3.githubusercontent.com/u/208074?v=4","gravatar_id":"","url":"https://api.github.com/users/derickr","html_url":"https://github.com/derickr","followers_url":"https://api.github.com/users/derickr/followers","following_url":"https://api.github.com/users/derickr/following{/other_user}","gists_url":"https://api.github.com/users/derickr/gists{/gist_id}","starred_url":"https://api.github.com/users/derickr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derickr/subscriptions","organizations_url":"https://api.github.com/users/derickr/orgs","repos_url":"https://api.github.com/users/derickr/repos","events_url":"https://api.github.com/users/derickr/events{/privacy}","received_events_url":"https://api.github.com/users/derickr/received_events","type":"User","site_admin":false},"repo":{"id":33925105,"name":"mongo-php-driver","full_name":"derickr/mongo-php-driver","owner":{"login":"derickr","id":208074,"avatar_url":"https://avatars3.githubusercontent.com/u/208074?v=4","gravatar_id":"","url":"https://api.github.com/users/derickr","html_url":"https://github.com/derickr","followers_url":"https://api.github.com/users/derickr/followers","following_url":"https://api.github.com/users/derickr/following{/other_user}","gists_url":"https://api.github.com/users/derickr/gists{/gist_id}","starred_url":"https://api.github.com/users/derickr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derickr/subscriptions","organizations_url":"https://api.github.com/users/derickr/orgs","repos_url":"https://api.github.com/users/derickr/repos","events_url":"https://api.github.com/users/derickr/events{/privacy}","received_events_url":"https://api.github.com/users/derickr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/derickr/mongo-php-driver","description":"MongoDB PHP driver (experimental)","fork":true,"url":"https://api.github.com/repos/derickr/mongo-php-driver","forks_url":"https://api.github.com/repos/derickr/mongo-php-driver/forks","keys_url":"https://api.github.com/repos/derickr/mongo-php-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/derickr/mongo-php-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/derickr/mongo-php-driver/teams","hooks_url":"https://api.github.com/repos/derickr/mongo-php-driver/hooks","issue_events_url":"https://api.github.com/repos/derickr/mongo-php-driver/issues/events{/number}","events_url":"https://api.github.com/repos/derickr/mongo-php-driver/events","assignees_url":"https://api.github.com/repos/derickr/mongo-php-driver/assignees{/user}","branches_url":"https://api.github.com/repos/derickr/mongo-php-driver/branches{/branch}","tags_url":"https://api.github.com/repos/derickr/mongo-php-driver/tags","blobs_url":"https://api.github.com/repos/derickr/mongo-php-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/derickr/mongo-php-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/derickr/mongo-php-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/derickr/mongo-php-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/derickr/mongo-php-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/derickr/mongo-php-driver/languages","stargazers_url":"https://api.github.com/repos/derickr/mongo-php-driver/stargazers","contributors_url":"https://api.github.com/repos/derickr/mongo-php-driver/contributors","subscribers_url":"https://api.github.com/repos/derickr/mongo-php-driver/subscribers","subscription_url":"https://api.github.com/repos/derickr/mongo-php-driver/subscription","commits_url":"https://api.github.com/repos/derickr/mongo-php-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/derickr/mongo-php-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/derickr/mongo-php-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/derickr/mongo-php-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/derickr/mongo-php-driver/contents/{+path}","compare_url":"https://api.github.com/repos/derickr/mongo-php-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/derickr/mongo-php-driver/merges","archive_url":"https://api.github.com/repos/derickr/mongo-php-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/derickr/mongo-php-driver/downloads","issues_url":"https://api.github.com/repos/derickr/mongo-php-driver/issues{/number}","pulls_url":"https://api.github.com/repos/derickr/mongo-php-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/derickr/mongo-php-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/derickr/mongo-php-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/derickr/mongo-php-driver/labels{/name}","releases_url":"https://api.github.com/repos/derickr/mongo-php-driver/releases{/id}","deployments_url":"https://api.github.com/repos/derickr/mongo-php-driver/deployments","created_at":"2015-04-14T10:16:35Z","updated_at":"2017-01-12T14:41:02Z","pushed_at":"2018-04-13T12:10:49Z","git_url":"git://github.com/derickr/mongo-php-driver.git","ssh_url":"git@github.com:derickr/mongo-php-driver.git","clone_url":"https://github.com/derickr/mongo-php-driver.git","svn_url":"https://github.com/derickr/mongo-php-driver","homepage":"","size":6763,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"e2aeebddb5016a66c954eb05e87acafe0d171717","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":19514152,"name":"mongo-php-driver","full_name":"mongodb/mongo-php-driver","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars1.githubusercontent.com/u/45120?v=4","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/mongo-php-driver","description":"MongoDB PHP driver","fork":false,"url":"https://api.github.com/repos/mongodb/mongo-php-driver","forks_url":"https://api.github.com/repos/mongodb/mongo-php-driver/forks","keys_url":"https://api.github.com/repos/mongodb/mongo-php-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/mongo-php-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/mongo-php-driver/teams","hooks_url":"https://api.github.com/repos/mongodb/mongo-php-driver/hooks","issue_events_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/mongo-php-driver/events","assignees_url":"https://api.github.com/repos/mongodb/mongo-php-driver/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/mongo-php-driver/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/mongo-php-driver/tags","blobs_url":"https://api.github.com/repos/mongodb/mongo-php-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/mongo-php-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/mongo-php-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/mongo-php-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/mongo-php-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/mongo-php-driver/languages","stargazers_url":"https://api.github.com/repos/mongodb/mongo-php-driver/stargazers","contributors_url":"https://api.github.com/repos/mongodb/mongo-php-driver/contributors","subscribers_url":"https://api.github.com/repos/mongodb/mongo-php-driver/subscribers","subscription_url":"https://api.github.com/repos/mongodb/mongo-php-driver/subscription","commits_url":"https://api.github.com/repos/mongodb/mongo-php-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/mongo-php-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/mongo-php-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/mongo-php-driver/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/mongo-php-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/mongo-php-driver/merges","archive_url":"https://api.github.com/repos/mongodb/mongo-php-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/mongo-php-driver/downloads","issues_url":"https://api.github.com/repos/mongodb/mongo-php-driver/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/mongo-php-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/mongo-php-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/mongo-php-driver/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/mongo-php-driver/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/mongo-php-driver/deployments","created_at":"2014-05-06T23:18:32Z","updated_at":"2018-04-15T08:57:25Z","pushed_at":"2018-04-16T14:15:16Z","git_url":"git://github.com/mongodb/mongo-php-driver.git","ssh_url":"git@github.com:mongodb/mongo-php-driver.git","clone_url":"https://github.com/mongodb/mongo-php-driver.git","svn_url":"https://github.com/mongodb/mongo-php-driver","homepage":"https://pecl.php.net/package/mongodb","size":6267,"stargazers_count":487,"watchers_count":487,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":132,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":132,"open_issues":24,"watchers":487,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793"},"html":{"href":"https://github.com/mongodb/mongo-php-driver/pull/793"},"issue":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/793"},"comments":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/issues/793/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/pulls/793/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/mongo-php-driver/statuses/67328be7c32866b5ecf1636e1585ec4ac43e1a65"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jmikola"}}