{"action":"created","comment":{"url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/comments/24069976","id":24069976,"diff_hunk":"@@ -50,171 +57,109 @@\n static ddb_converter_t plugin;\n static DB_functions_t *deadbeef;\n \n-static ddb_encoder_preset_t *encoder_presets;\n-static ddb_dsp_preset_t *dsp_presets;\n+struct encoder_preset_link {\n+    ddb_encoder_preset_t preset;\n+    struct encoder_preset_link *next;\n+};\n+static struct encoder_preset_link *encoder_presets;\n \n-ddb_encoder_preset_t *\n-encoder_preset_alloc (void) {\n-    ddb_encoder_preset_t *p = malloc (sizeof (ddb_encoder_preset_t));\n-    if (!p) {\n-        fprintf (stderr, \"failed to alloc ddb_encoder_preset_t\\n\");\n-        return NULL;\n-    }\n-    memset (p, 0, sizeof (ddb_encoder_preset_t));\n-    return p;\n-}\n+struct dsp_preset_link {\n+    ddb_dsp_preset_t preset;\n+    struct dsp_preset_link *next;\n+};\n+static struct dsp_preset_link *dsp_presets;\n \n-void\n-encoder_preset_free (ddb_encoder_preset_t *p) {\n-    if (p) {\n-        if (p->title) {\n-            free (p->title);\n-        }\n-        if (p->ext) {\n-            free (p->ext);\n-        }\n-        if (p->encoder) {\n-            free (p->encoder);\n-        }\n-        free (p);\n+static int\n+check_dir(const char *path)\n+{\n+    struct stat stat_struct;\n+    if (!stat(path, &stat_struct)) {\n+        return S_ISDIR(stat_struct.st_mode);\n     }\n-}\n-\n-ddb_encoder_preset_t *\n-encoder_preset_load (const char *fname) {\n-    int err = 1;\n-    FILE *fp = fopen (fname, \"rt\");\n-    if (!fp) {\n-        return NULL;\n+    if (errno != ENOENT) {\n+        return 0;\n     }\n-    ddb_encoder_preset_t *p = encoder_preset_alloc ();\n \n-    char str[1024];\n-    while (fgets (str, sizeof (str), fp)) {\n-        // chomp\n-        char *cr = str + strlen (str) - 1;\n-        while (*cr == '\\n') {\n-            cr--;\n-        }\n-        cr++;\n-        *cr = 0;\n+    char* dir = strdup(path);","path":"plugins/converter/converter.c","position":144,"original_position":144,"commit_id":"9ed8d0ef2754333c1840e1512d518a499970e836","original_commit_id":"9ed8d0ef2754333c1840e1512d518a499970e836","user":{"login":"Alexey-Yakovenko","id":1895698,"avatar_url":"https://avatars.githubusercontent.com/u/1895698?v=3","gravatar_id":"","url":"https://api.github.com/users/Alexey-Yakovenko","html_url":"https://github.com/Alexey-Yakovenko","followers_url":"https://api.github.com/users/Alexey-Yakovenko/followers","following_url":"https://api.github.com/users/Alexey-Yakovenko/following{/other_user}","gists_url":"https://api.github.com/users/Alexey-Yakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/Alexey-Yakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alexey-Yakovenko/subscriptions","organizations_url":"https://api.github.com/users/Alexey-Yakovenko/orgs","repos_url":"https://api.github.com/users/Alexey-Yakovenko/repos","events_url":"https://api.github.com/users/Alexey-Yakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/Alexey-Yakovenko/received_events","type":"User","site_admin":false},"body":"The path that you pass to check_dir is writable, it's a copy that you make in ensure_dir.\r\nThe check_dir can be modified to accept a non-const pointer, and use dirname on that. Then you don't need any allocations at all.","created_at":"2015-02-04T08:58:19Z","updated_at":"2015-02-04T08:58:19Z","html_url":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69#discussion_r24069976","pull_request_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/comments/24069976"},"html":{"href":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69#discussion_r24069976"},"pull_request":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69","id":27133487,"html_url":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69","diff_url":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69.diff","patch_url":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69.patch","issue_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/69","number":69,"state":"closed","locked":false,"title":"converter 2.0","user":{"login":"Lithopsian","id":7702742,"avatar_url":"https://avatars.githubusercontent.com/u/7702742?v=3","gravatar_id":"","url":"https://api.github.com/users/Lithopsian","html_url":"https://github.com/Lithopsian","followers_url":"https://api.github.com/users/Lithopsian/followers","following_url":"https://api.github.com/users/Lithopsian/following{/other_user}","gists_url":"https://api.github.com/users/Lithopsian/gists{/gist_id}","starred_url":"https://api.github.com/users/Lithopsian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lithopsian/subscriptions","organizations_url":"https://api.github.com/users/Lithopsian/orgs","repos_url":"https://api.github.com/users/Lithopsian/repos","events_url":"https://api.github.com/users/Lithopsian/events{/privacy}","received_events_url":"https://api.github.com/users/Lithopsian/received_events","type":"User","site_admin":false},"body":"Some minor spacing changes, otherwise as before but hopefully synced and mergeable.","created_at":"2015-01-09T22:13:32Z","updated_at":"2015-02-04T08:58:19Z","closed_at":"2015-02-02T17:59:38Z","merged_at":null,"merge_commit_sha":"851edc230007a43ed523026b499c63d323aa185f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69/commits","review_comments_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69/comments","review_comment_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/69/comments","statuses_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/statuses/9ed8d0ef2754333c1840e1512d518a499970e836","head":{"label":"Lithopsian:converter","ref":"converter","sha":"9ed8d0ef2754333c1840e1512d518a499970e836","user":{"login":"Lithopsian","id":7702742,"avatar_url":"https://avatars.githubusercontent.com/u/7702742?v=3","gravatar_id":"","url":"https://api.github.com/users/Lithopsian","html_url":"https://github.com/Lithopsian","followers_url":"https://api.github.com/users/Lithopsian/followers","following_url":"https://api.github.com/users/Lithopsian/following{/other_user}","gists_url":"https://api.github.com/users/Lithopsian/gists{/gist_id}","starred_url":"https://api.github.com/users/Lithopsian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lithopsian/subscriptions","organizations_url":"https://api.github.com/users/Lithopsian/orgs","repos_url":"https://api.github.com/users/Lithopsian/repos","events_url":"https://api.github.com/users/Lithopsian/events{/privacy}","received_events_url":"https://api.github.com/users/Lithopsian/received_events","type":"User","site_admin":false},"repo":{"id":20462721,"name":"deadbeef","full_name":"Lithopsian/deadbeef","owner":{"login":"Lithopsian","id":7702742,"avatar_url":"https://avatars.githubusercontent.com/u/7702742?v=3","gravatar_id":"","url":"https://api.github.com/users/Lithopsian","html_url":"https://github.com/Lithopsian","followers_url":"https://api.github.com/users/Lithopsian/followers","following_url":"https://api.github.com/users/Lithopsian/following{/other_user}","gists_url":"https://api.github.com/users/Lithopsian/gists{/gist_id}","starred_url":"https://api.github.com/users/Lithopsian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lithopsian/subscriptions","organizations_url":"https://api.github.com/users/Lithopsian/orgs","repos_url":"https://api.github.com/users/Lithopsian/repos","events_url":"https://api.github.com/users/Lithopsian/events{/privacy}","received_events_url":"https://api.github.com/users/Lithopsian/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Lithopsian/deadbeef","description":"DeaDBeeF Player (official repository)","fork":true,"url":"https://api.github.com/repos/Lithopsian/deadbeef","forks_url":"https://api.github.com/repos/Lithopsian/deadbeef/forks","keys_url":"https://api.github.com/repos/Lithopsian/deadbeef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lithopsian/deadbeef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lithopsian/deadbeef/teams","hooks_url":"https://api.github.com/repos/Lithopsian/deadbeef/hooks","issue_events_url":"https://api.github.com/repos/Lithopsian/deadbeef/issues/events{/number}","events_url":"https://api.github.com/repos/Lithopsian/deadbeef/events","assignees_url":"https://api.github.com/repos/Lithopsian/deadbeef/assignees{/user}","branches_url":"https://api.github.com/repos/Lithopsian/deadbeef/branches{/branch}","tags_url":"https://api.github.com/repos/Lithopsian/deadbeef/tags","blobs_url":"https://api.github.com/repos/Lithopsian/deadbeef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lithopsian/deadbeef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lithopsian/deadbeef/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lithopsian/deadbeef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lithopsian/deadbeef/statuses/{sha}","languages_url":"https://api.github.com/repos/Lithopsian/deadbeef/languages","stargazers_url":"https://api.github.com/repos/Lithopsian/deadbeef/stargazers","contributors_url":"https://api.github.com/repos/Lithopsian/deadbeef/contributors","subscribers_url":"https://api.github.com/repos/Lithopsian/deadbeef/subscribers","subscription_url":"https://api.github.com/repos/Lithopsian/deadbeef/subscription","commits_url":"https://api.github.com/repos/Lithopsian/deadbeef/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lithopsian/deadbeef/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lithopsian/deadbeef/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lithopsian/deadbeef/issues/comments/{number}","contents_url":"https://api.github.com/repos/Lithopsian/deadbeef/contents/{+path}","compare_url":"https://api.github.com/repos/Lithopsian/deadbeef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lithopsian/deadbeef/merges","archive_url":"https://api.github.com/repos/Lithopsian/deadbeef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lithopsian/deadbeef/downloads","issues_url":"https://api.github.com/repos/Lithopsian/deadbeef/issues{/number}","pulls_url":"https://api.github.com/repos/Lithopsian/deadbeef/pulls{/number}","milestones_url":"https://api.github.com/repos/Lithopsian/deadbeef/milestones{/number}","notifications_url":"https://api.github.com/repos/Lithopsian/deadbeef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lithopsian/deadbeef/labels{/name}","releases_url":"https://api.github.com/repos/Lithopsian/deadbeef/releases{/id}","created_at":"2014-06-03T22:54:39Z","updated_at":"2015-01-09T11:13:14Z","pushed_at":"2015-01-20T17:46:41Z","git_url":"git://github.com/Lithopsian/deadbeef.git","ssh_url":"git@github.com:Lithopsian/deadbeef.git","clone_url":"https://github.com/Lithopsian/deadbeef.git","svn_url":"https://github.com/Lithopsian/deadbeef","homepage":"http://deadbeef.sf.net","size":46106,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Alexey-Yakovenko:master","ref":"master","sha":"2185977c93964dfcbd41c373189d4855f7ffde8a","user":{"login":"Alexey-Yakovenko","id":1895698,"avatar_url":"https://avatars.githubusercontent.com/u/1895698?v=3","gravatar_id":"","url":"https://api.github.com/users/Alexey-Yakovenko","html_url":"https://github.com/Alexey-Yakovenko","followers_url":"https://api.github.com/users/Alexey-Yakovenko/followers","following_url":"https://api.github.com/users/Alexey-Yakovenko/following{/other_user}","gists_url":"https://api.github.com/users/Alexey-Yakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/Alexey-Yakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alexey-Yakovenko/subscriptions","organizations_url":"https://api.github.com/users/Alexey-Yakovenko/orgs","repos_url":"https://api.github.com/users/Alexey-Yakovenko/repos","events_url":"https://api.github.com/users/Alexey-Yakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/Alexey-Yakovenko/received_events","type":"User","site_admin":false},"repo":{"id":15237541,"name":"deadbeef","full_name":"Alexey-Yakovenko/deadbeef","owner":{"login":"Alexey-Yakovenko","id":1895698,"avatar_url":"https://avatars.githubusercontent.com/u/1895698?v=3","gravatar_id":"","url":"https://api.github.com/users/Alexey-Yakovenko","html_url":"https://github.com/Alexey-Yakovenko","followers_url":"https://api.github.com/users/Alexey-Yakovenko/followers","following_url":"https://api.github.com/users/Alexey-Yakovenko/following{/other_user}","gists_url":"https://api.github.com/users/Alexey-Yakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/Alexey-Yakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alexey-Yakovenko/subscriptions","organizations_url":"https://api.github.com/users/Alexey-Yakovenko/orgs","repos_url":"https://api.github.com/users/Alexey-Yakovenko/repos","events_url":"https://api.github.com/users/Alexey-Yakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/Alexey-Yakovenko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Alexey-Yakovenko/deadbeef","description":"DeaDBeeF Player (official repository)","fork":false,"url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef","forks_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/forks","keys_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/teams","hooks_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/hooks","issue_events_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/events{/number}","events_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/events","assignees_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/assignees{/user}","branches_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/branches{/branch}","tags_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/tags","blobs_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/git/refs{/sha}","trees_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/statuses/{sha}","languages_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/languages","stargazers_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/stargazers","contributors_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/contributors","subscribers_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/subscribers","subscription_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/subscription","commits_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/commits{/sha}","git_commits_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/git/commits{/sha}","comments_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/comments{/number}","issue_comment_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/comments/{number}","contents_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/contents/{+path}","compare_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/merges","archive_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/downloads","issues_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues{/number}","pulls_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls{/number}","milestones_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/milestones{/number}","notifications_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/labels{/name}","releases_url":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/releases{/id}","created_at":"2013-12-16T21:21:05Z","updated_at":"2015-02-03T20:16:25Z","pushed_at":"2015-02-03T20:16:25Z","git_url":"git://github.com/Alexey-Yakovenko/deadbeef.git","ssh_url":"git@github.com:Alexey-Yakovenko/deadbeef.git","clone_url":"https://github.com/Alexey-Yakovenko/deadbeef.git","svn_url":"https://github.com/Alexey-Yakovenko/deadbeef","homepage":"http://deadbeef.sf.net","size":68025,"stargazers_count":119,"watchers_count":119,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":0,"forks":24,"open_issues":0,"watchers":119,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69"},"html":{"href":"https://github.com/Alexey-Yakovenko/deadbeef/pull/69"},"issue":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/69"},"comments":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/Alexey-Yakovenko/deadbeef/statuses/9ed8d0ef2754333c1840e1512d518a499970e836"}}}}