{"action":"created","issue":{"url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/15","repository_url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree","labels_url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/15/comments","events_url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/15/events","html_url":"https://github.com/abdullahemad12/Cranberry-Btree/issues/15","id":345676365,"node_id":"MDU6SXNzdWUzNDU2NzYzNjU=","number":15,"title":"Function to detach a cloned btree","user":{"login":"abdullahemad12","id":20978361,"node_id":"MDQ6VXNlcjIwOTc4MzYx","avatar_url":"https://avatars1.githubusercontent.com/u/20978361?v=4","gravatar_id":"","url":"https://api.github.com/users/abdullahemad12","html_url":"https://github.com/abdullahemad12","followers_url":"https://api.github.com/users/abdullahemad12/followers","following_url":"https://api.github.com/users/abdullahemad12/following{/other_user}","gists_url":"https://api.github.com/users/abdullahemad12/gists{/gist_id}","starred_url":"https://api.github.com/users/abdullahemad12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abdullahemad12/subscriptions","organizations_url":"https://api.github.com/users/abdullahemad12/orgs","repos_url":"https://api.github.com/users/abdullahemad12/repos","events_url":"https://api.github.com/users/abdullahemad12/events{/privacy}","received_events_url":"https://api.github.com/users/abdullahemad12/received_events","type":"User","site_admin":false},"labels":[{"id":974814992,"node_id":"MDU6TGFiZWw5NzQ4MTQ5OTI=","url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/labels/Testing","name":"Testing","color":"b60205","default":false},{"id":966734189,"node_id":"MDU6TGFiZWw5NjY3MzQxODk=","url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/labels/enhancement","name":"enhancement","color":"a2eeef","default":true},{"id":1009032618,"node_id":"MDU6TGFiZWwxMDA5MDMyNjE4","url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/labels/first-timers-only","name":"first-timers-only","color":"0052cc","default":false},{"id":966734191,"node_id":"MDU6TGFiZWw5NjY3MzQxOTE=","url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/labels/good%20first%20issue","name":"good first issue","color":"7057ff","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-30T09:19:19Z","updated_at":"2018-08-26T13:31:40Z","closed_at":null,"author_association":"OWNER","body":"# Task\r\n create  a function that turns a cloned tree into a normal tree\r\n\r\n# How \r\nFor now, because the cloned btree is not associated with the original, the only thing that needs to be done is to set the boolean is_cloned to true. Moreover, you will have to walk through the tree nodes and update the objects of the entries using the copy_object function\r\n\r\n# Prototype\r\n\r\n```\r\n/**\r\n  * cranbtree_t*, void* (* copy_object)(void*) -> void\r\n  * EFFECTS: detaches a cloned cranbtree_t from its parent. If copy_object is not NULL, cbt_detach_clone \r\n  * will use it to make a new copy of every object in the tree.\r\n  * MODIFIES: cranbtree_t* cbt\r\n  * PARAMETERS: \r\n  * - cranbtree_t* cbt: a pointer to a cloned cranbtree\r\n  * - void* (* copy_object)(void*): a pointer to a function (void* -> void*) that will take the old object as a parameter\r\n  *\t\t\t\t\t\t\t\t\tand returns a pointer to a copy of the object. This will be invoked on every object in the cranbtree \r\n  *\r\n  * NOTE: This should generally be used when your cloned cranbtree will start storing objects different \r\n  * \t   then those of the original; However, when using it, it becomes your responsibility to free \r\n  *\t\t   and manipulate objects correctly\r\n  */\r\nvoid cbt_detach_clone(cranbtree_t* cbt, void* (* copy_object)(void*))\r\n```\r\n\r\n# where to place the code\r\nPut your code in src/cranbtree.c where you will find a stub for the function. Any additional helper functions should be placed in src/lib/clone.c and their prototypes should go in src/lib/lib.h\r\n\r\n# Tests\r\nThe implementation should pass the following three tests found in test/testsuite.c\r\n1. cbt_detach_clone_test1\r\n2. cbt_detach_clone_test2\r\n3. cbt_detach_clone_test3"},"comment":{"url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/comments/416039185","html_url":"https://github.com/abdullahemad12/Cranberry-Btree/issues/15#issuecomment-416039185","issue_url":"https://api.github.com/repos/abdullahemad12/Cranberry-Btree/issues/15","id":416039185,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjAzOTE4NQ==","user":{"login":"stevep1983","id":20347119,"node_id":"MDQ6VXNlcjIwMzQ3MTE5","avatar_url":"https://avatars1.githubusercontent.com/u/20347119?v=4","gravatar_id":"","url":"https://api.github.com/users/stevep1983","html_url":"https://github.com/stevep1983","followers_url":"https://api.github.com/users/stevep1983/followers","following_url":"https://api.github.com/users/stevep1983/following{/other_user}","gists_url":"https://api.github.com/users/stevep1983/gists{/gist_id}","starred_url":"https://api.github.com/users/stevep1983/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevep1983/subscriptions","organizations_url":"https://api.github.com/users/stevep1983/orgs","repos_url":"https://api.github.com/users/stevep1983/repos","events_url":"https://api.github.com/users/stevep1983/events{/privacy}","received_events_url":"https://api.github.com/users/stevep1983/received_events","type":"User","site_admin":false},"created_at":"2018-08-26T13:31:40Z","updated_at":"2018-08-26T13:31:40Z","author_association":"NONE","body":"I think I have this mostly implemented. Thanks for this project, it's very well designed. There's just one thing I want to clarify.\r\n\r\n1) In the `cbt_detach_clone_test2` unit test, `cbt_destroy` is called on both the original tree and the \"detached\" clone. In this instance, the detached clone was not pass a `copy_object` function.\r\n\r\nI can see two possibilities in the case the `cbt_detach_clone` is not given a `copy_object`.\r\n- We simply set the is_clone flag to false and do nothing to the objects, or\r\n- - In this case, the `cbt_destroy` will cause a double `free`\r\n- We leave the tree unchanged.\r\n- - In this case, the \t`CU_ASSERT_EQUAL(clone->is_clone, false)` will fail.\r\n\r\n https://github.com/abdullahemad12/Cranberry-Btree/blob/af7c1a1d96c82e1d6ea67eb12c5f835e8bbe7a51/test/testsuite.c#L1655"}}
{"actor":{"display_login":"stevep1983"}}