{"action":"created","comment":{"url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/comments/67604048","id":67604048,"diff_hunk":"@@ -0,0 +1,186 @@\n+#include <stdio.h>\n+#include <stdlib.h>\n+#define ASSERT(x) printf(\"Assertion: \" #x \" = %d\\n\", (x))\n+\n+typedef int data_t;\n+\n+typedef struct node {\n+  data_t data;\n+  struct node *next;\n+} node;\n+\n+#define CHECK_ALLOC(ptr)\t\t\t\t\t\t\\\n+  if (!ptr) {\t\t\t\t\t\t\t\t\\\n+    printf(\"Error allocating memory for %s in  %s: %d line\", #ptr, __func__, __LINE__-1); \\\n+    exit(2);\t\t\t\t\t\t\t\t\\\n+  }\n+\n+node* list_create(data_t data){\n+  node* first = (node*)malloc(sizeof(node));\n+  CHECK_ALLOC(first);\n+  first->data = data;\n+  first->next = NULL;\n+  return first;\n+}\n+\n+\n+void list_free(node* first){\n+  while (first != NULL)\n+    {\n+      node* tmp = first;\n+      first = first->next;\n+      free(tmp);\n+    }\n+}\n+\n+void list_append_element_end(node* list, int new_element){\n+  node* new_node = (node*)malloc(sizeof(node)); \n+  CHECK_ALLOC(new_node); \n+  new_node->data = new_element;\n+  new_node->next = NULL;\n+\n+  if (list == NULL){\n+    list = new_node;\n+  }\n+  while (list->next != NULL)\n+    list = list->next;\n+\n+  list->next = new_node;\n+}","path":"linked_list/single_linked_list.c","position":49,"original_position":49,"commit_id":"fe756d726278fb211f2f3b5c0a589af66d8b0570","original_commit_id":"fe756d726278fb211f2f3b5c0a589af66d8b0570","user":{"login":"disconnect3d","id":10009354,"avatar_url":"https://avatars.githubusercontent.com/u/10009354?v=3","gravatar_id":"","url":"https://api.github.com/users/disconnect3d","html_url":"https://github.com/disconnect3d","followers_url":"https://api.github.com/users/disconnect3d/followers","following_url":"https://api.github.com/users/disconnect3d/following{/other_user}","gists_url":"https://api.github.com/users/disconnect3d/gists{/gist_id}","starred_url":"https://api.github.com/users/disconnect3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/disconnect3d/subscriptions","organizations_url":"https://api.github.com/users/disconnect3d/orgs","repos_url":"https://api.github.com/users/disconnect3d/repos","events_url":"https://api.github.com/users/disconnect3d/events{/privacy}","received_events_url":"https://api.github.com/users/disconnect3d/received_events","type":"User","site_admin":false},"body":"1) `list_append_element_end` is pretty long as for a function (sometimes very long function names are okay, e.g. for test functions) - I would name it just `list_append`, as `append` is known to add to an end (e.g. `.append()` method in Python).\r\n2) This won't work when `list == NULL`. Add such a test and try to find out what's wrong:\r\n```\r\nvoid test_append_to_empty() {\r\n    node* head = NULL;\r\n    list_append_element_end(head, 1);\r\n    ASSERT(list != NULL);\r\n    ASSERT(list->data == 1);\r\n    ASSERT(list->next == NULL);\r\n    list_free(head);\r\n}\r\n```","created_at":"2016-06-18T17:38:34Z","updated_at":"2016-06-18T17:38:34Z","html_url":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2#discussion_r67604048","pull_request_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/comments/67604048"},"html":{"href":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2#discussion_r67604048"},"pull_request":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2","id":74337169,"html_url":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2","diff_url":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2.diff","patch_url":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2.patch","issue_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/2","number":2,"state":"open","locked":false,"title":"Single linked list","user":{"login":"Layika","id":17379475,"avatar_url":"https://avatars.githubusercontent.com/u/17379475?v=3","gravatar_id":"","url":"https://api.github.com/users/Layika","html_url":"https://github.com/Layika","followers_url":"https://api.github.com/users/Layika/followers","following_url":"https://api.github.com/users/Layika/following{/other_user}","gists_url":"https://api.github.com/users/Layika/gists{/gist_id}","starred_url":"https://api.github.com/users/Layika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Layika/subscriptions","organizations_url":"https://api.github.com/users/Layika/orgs","repos_url":"https://api.github.com/users/Layika/repos","events_url":"https://api.github.com/users/Layika/events{/privacy}","received_events_url":"https://api.github.com/users/Layika/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-18T13:30:30Z","updated_at":"2016-06-18T17:38:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"db98f055486c5b54a105ecfb503859e1643d9e52","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/2/comments","statuses_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/statuses/fe756d726278fb211f2f3b5c0a589af66d8b0570","head":{"label":"Layika:develop","ref":"develop","sha":"fe756d726278fb211f2f3b5c0a589af66d8b0570","user":{"login":"Layika","id":17379475,"avatar_url":"https://avatars.githubusercontent.com/u/17379475?v=3","gravatar_id":"","url":"https://api.github.com/users/Layika","html_url":"https://github.com/Layika","followers_url":"https://api.github.com/users/Layika/followers","following_url":"https://api.github.com/users/Layika/following{/other_user}","gists_url":"https://api.github.com/users/Layika/gists{/gist_id}","starred_url":"https://api.github.com/users/Layika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Layika/subscriptions","organizations_url":"https://api.github.com/users/Layika/orgs","repos_url":"https://api.github.com/users/Layika/repos","events_url":"https://api.github.com/users/Layika/events{/privacy}","received_events_url":"https://api.github.com/users/Layika/received_events","type":"User","site_admin":false},"repo":{"id":60545246,"name":"learn_c_the_disconnected_way","full_name":"Layika/learn_c_the_disconnected_way","owner":{"login":"Layika","id":17379475,"avatar_url":"https://avatars.githubusercontent.com/u/17379475?v=3","gravatar_id":"","url":"https://api.github.com/users/Layika","html_url":"https://github.com/Layika","followers_url":"https://api.github.com/users/Layika/followers","following_url":"https://api.github.com/users/Layika/following{/other_user}","gists_url":"https://api.github.com/users/Layika/gists{/gist_id}","starred_url":"https://api.github.com/users/Layika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Layika/subscriptions","organizations_url":"https://api.github.com/users/Layika/orgs","repos_url":"https://api.github.com/users/Layika/repos","events_url":"https://api.github.com/users/Layika/events{/privacy}","received_events_url":"https://api.github.com/users/Layika/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Layika/learn_c_the_disconnected_way","description":"","fork":false,"url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way","forks_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/forks","keys_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/teams","hooks_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/hooks","issue_events_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/events{/number}","events_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/events","assignees_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/assignees{/user}","branches_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/branches{/branch}","tags_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/tags","blobs_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/refs{/sha}","trees_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/statuses/{sha}","languages_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/languages","stargazers_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/stargazers","contributors_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/contributors","subscribers_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/subscribers","subscription_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/subscription","commits_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/commits{/sha}","git_commits_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/commits{/sha}","comments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/comments{/number}","issue_comment_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/comments{/number}","contents_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/contents/{+path}","compare_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/merges","archive_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/downloads","issues_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues{/number}","pulls_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls{/number}","milestones_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/milestones{/number}","notifications_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/labels{/name}","releases_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/releases{/id}","deployments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/deployments","created_at":"2016-06-06T16:57:22Z","updated_at":"2016-06-06T21:36:41Z","pushed_at":"2016-06-18T17:32:17Z","git_url":"git://github.com/Layika/learn_c_the_disconnected_way.git","ssh_url":"git@github.com:Layika/learn_c_the_disconnected_way.git","clone_url":"https://github.com/Layika/learn_c_the_disconnected_way.git","svn_url":"https://github.com/Layika/learn_c_the_disconnected_way","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Layika:master","ref":"master","sha":"2b9f013d5b0f6f5abfdaeb8ae7dfcba934c3b35f","user":{"login":"Layika","id":17379475,"avatar_url":"https://avatars.githubusercontent.com/u/17379475?v=3","gravatar_id":"","url":"https://api.github.com/users/Layika","html_url":"https://github.com/Layika","followers_url":"https://api.github.com/users/Layika/followers","following_url":"https://api.github.com/users/Layika/following{/other_user}","gists_url":"https://api.github.com/users/Layika/gists{/gist_id}","starred_url":"https://api.github.com/users/Layika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Layika/subscriptions","organizations_url":"https://api.github.com/users/Layika/orgs","repos_url":"https://api.github.com/users/Layika/repos","events_url":"https://api.github.com/users/Layika/events{/privacy}","received_events_url":"https://api.github.com/users/Layika/received_events","type":"User","site_admin":false},"repo":{"id":60545246,"name":"learn_c_the_disconnected_way","full_name":"Layika/learn_c_the_disconnected_way","owner":{"login":"Layika","id":17379475,"avatar_url":"https://avatars.githubusercontent.com/u/17379475?v=3","gravatar_id":"","url":"https://api.github.com/users/Layika","html_url":"https://github.com/Layika","followers_url":"https://api.github.com/users/Layika/followers","following_url":"https://api.github.com/users/Layika/following{/other_user}","gists_url":"https://api.github.com/users/Layika/gists{/gist_id}","starred_url":"https://api.github.com/users/Layika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Layika/subscriptions","organizations_url":"https://api.github.com/users/Layika/orgs","repos_url":"https://api.github.com/users/Layika/repos","events_url":"https://api.github.com/users/Layika/events{/privacy}","received_events_url":"https://api.github.com/users/Layika/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Layika/learn_c_the_disconnected_way","description":"","fork":false,"url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way","forks_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/forks","keys_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/teams","hooks_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/hooks","issue_events_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/events{/number}","events_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/events","assignees_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/assignees{/user}","branches_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/branches{/branch}","tags_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/tags","blobs_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/refs{/sha}","trees_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/statuses/{sha}","languages_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/languages","stargazers_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/stargazers","contributors_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/contributors","subscribers_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/subscribers","subscription_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/subscription","commits_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/commits{/sha}","git_commits_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/git/commits{/sha}","comments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/comments{/number}","issue_comment_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/comments{/number}","contents_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/contents/{+path}","compare_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/merges","archive_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/downloads","issues_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues{/number}","pulls_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls{/number}","milestones_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/milestones{/number}","notifications_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/labels{/name}","releases_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/releases{/id}","deployments_url":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/deployments","created_at":"2016-06-06T16:57:22Z","updated_at":"2016-06-06T21:36:41Z","pushed_at":"2016-06-18T17:32:17Z","git_url":"git://github.com/Layika/learn_c_the_disconnected_way.git","ssh_url":"git@github.com:Layika/learn_c_the_disconnected_way.git","clone_url":"https://github.com/Layika/learn_c_the_disconnected_way.git","svn_url":"https://github.com/Layika/learn_c_the_disconnected_way","homepage":null,"size":6,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2"},"html":{"href":"https://github.com/Layika/learn_c_the_disconnected_way/pull/2"},"issue":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/2"},"comments":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Layika/learn_c_the_disconnected_way/statuses/fe756d726278fb211f2f3b5c0a589af66d8b0570"}}}}
{"actor":{"display_login":"disconnect3d"}}