{"action":"created","issue":{"url":"https://api.github.com/repos/livecode/livecode/issues/4253","repository_url":"https://api.github.com/repos/livecode/livecode","labels_url":"https://api.github.com/repos/livecode/livecode/issues/4253/labels{/name}","comments_url":"https://api.github.com/repos/livecode/livecode/issues/4253/comments","events_url":"https://api.github.com/repos/livecode/livecode/issues/4253/events","html_url":"https://github.com/livecode/livecode/pull/4253","id":164502993,"number":4253,"title":"Fix many allocation/deallocation mismatches.","user":{"login":"peter-b","id":47528,"avatar_url":"https://avatars.githubusercontent.com/u/47528?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-b","html_url":"https://github.com/peter-b","followers_url":"https://api.github.com/users/peter-b/followers","following_url":"https://api.github.com/users/peter-b/following{/other_user}","gists_url":"https://api.github.com/users/peter-b/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-b/subscriptions","organizations_url":"https://api.github.com/users/peter-b/orgs","repos_url":"https://api.github.com/users/peter-b/repos","events_url":"https://api.github.com/users/peter-b/events{/privacy}","received_events_url":"https://api.github.com/users/peter-b/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/livecode/livecode/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/livecode/livecode/labels/vulcan/reviewed","name":"vulcan/reviewed","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/livecode/livecode/milestones/112","html_url":"https://github.com/livecode/livecode/milestones/8.1.0-dp-3","labels_url":"https://api.github.com/repos/livecode/livecode/milestones/112/labels","id":1853208,"number":112,"title":"8.1.0-dp-3","description":null,"creator":{"login":"peter-b","id":47528,"avatar_url":"https://avatars.githubusercontent.com/u/47528?v=3","gravatar_id":"","url":"https://api.github.com/users/peter-b","html_url":"https://github.com/peter-b","followers_url":"https://api.github.com/users/peter-b/followers","following_url":"https://api.github.com/users/peter-b/following{/other_user}","gists_url":"https://api.github.com/users/peter-b/gists{/gist_id}","starred_url":"https://api.github.com/users/peter-b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peter-b/subscriptions","organizations_url":"https://api.github.com/users/peter-b/orgs","repos_url":"https://api.github.com/users/peter-b/repos","events_url":"https://api.github.com/users/peter-b/events{/privacy}","received_events_url":"https://api.github.com/users/peter-b/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":20,"state":"open","created_at":"2016-06-28T16:43:59Z","updated_at":"2016-07-08T11:31:15Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-07-08T10:29:39Z","updated_at":"2016-07-08T11:34:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/livecode/livecode/pulls/4253","html_url":"https://github.com/livecode/livecode/pull/4253","diff_url":"https://github.com/livecode/livecode/pull/4253.diff","patch_url":"https://github.com/livecode/livecode/pull/4253.patch"},"body":"The LiveCode engine uses three different allocators with distinct\r\nsemantics.\r\n\r\n- `malloc()`/`free()`: these are C library procedures, usually\r\n  accessed via the `MCMemory*` libfoundation functions; they allocate\r\n  memory on the heap and do no C++ construction or destruction of\r\n  their contents.\r\n\r\n- `new`/`delete`: these C++ operators allocate/deallocate a single\r\n  instance on the heap, and calls its constructor/destructor.\r\n\r\n- `new[]`/`delete[]`: these C++ operators allocate/deallocate an sized\r\n  array of instances on the heap, and call the constructor/destructor\r\n  for each of them.\r\n\r\nMismatch (e.g. allocating with `new[]` and freeing with `free()` is a\r\nresource management error, since it can result in something having a\r\ndestructor called when it shouldn't (or vice versa).  Both Coverity\r\nScan and the newest version of valgrind detect mismatched use.\r\n\r\nThis patch is a mostly mechanical replacement of release statements to\r\nmatch the corresponding allocators, with addition of annotation of\r\nwhat the expected allocator is.  (I added the annotation to help me\r\ndetect when multiple codepaths were allocating in conflicting\r\nways). As part of this, I changed a couple of inconsistent allocation\r\npaths.\r\n\r\nA particular error that occurs frequently is using an\r\n`MCAutoPointer<T>` to manage a `T*` that was created using `malloc()`;\r\nin particular, the usual error is to try and put the result of a\r\nlibfoundation function that allocates a buffer into an\r\n`MCAutoPointer<T>`.  This won't work, because libfoundation always\r\nallocates memory with `malloc()`, and `MCAutoPointer` always destroys\r\nits contents with `delete`.  Several codepaths are corrected to use an\r\nappropriate `MCAutoCustomPointer` instead."},"comment":{"url":"https://api.github.com/repos/livecode/livecode/issues/comments/231338267","html_url":"https://github.com/livecode/livecode/pull/4253#issuecomment-231338267","issue_url":"https://api.github.com/repos/livecode/livecode/issues/4253","id":231338267,"user":{"login":"livecode-vulcan","id":11739650,"avatar_url":"https://avatars.githubusercontent.com/u/11739650?v=3","gravatar_id":"","url":"https://api.github.com/users/livecode-vulcan","html_url":"https://github.com/livecode-vulcan","followers_url":"https://api.github.com/users/livecode-vulcan/followers","following_url":"https://api.github.com/users/livecode-vulcan/following{/other_user}","gists_url":"https://api.github.com/users/livecode-vulcan/gists{/gist_id}","starred_url":"https://api.github.com/users/livecode-vulcan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/livecode-vulcan/subscriptions","organizations_url":"https://api.github.com/users/livecode-vulcan/orgs","repos_url":"https://api.github.com/users/livecode-vulcan/repos","events_url":"https://api.github.com/users/livecode-vulcan/events{/privacy}","received_events_url":"https://api.github.com/users/livecode-vulcan/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T11:34:20Z","updated_at":"2016-07-08T11:34:20Z","body":"😎 test success 90de18b81742435248dccb0dc957a67bd590aba4\n\n* try-community-linux-x86: [success](https://vulcan.livecode.com/builders/try-community-linux-x86/builds/2767)\n* try-community-mac: [success](https://vulcan.livecode.com/builders/try-community-mac/builds/2776)\n* try-community-linux-x86_64: [success](https://vulcan.livecode.com/builders/try-community-linux-x86_64/builds/2762)\n* try-community-emscripten: [success](https://vulcan.livecode.com/builders/try-community-emscripten/builds/2778)\n* try-community-ios: [success](https://vulcan.livecode.com/builders/try-community-ios/builds/2784)\n* try-community-win-x86: [success](https://vulcan.livecode.com/builders/try-community-win-x86/builds/2788)\n* try-community-android-armv6: [success](https://vulcan.livecode.com/builders/try-community-android-armv6/builds/2806)\n"}}
{"actor":{"display_login":"livecode-vulcan"}}