esl/exml — pull request #8 by RGafiyatullin (2014-09-14 23:40:24+00:00)
Title: exml_event.c: enif_open_resource_type for "parser_pointer" does not specify the destructor function.

The following snippet contains some helper funs I would like to use to demonstrate the issue.
Just paste them into your REPL: https://gist.github.com/RGafiyatullin/675b97dc76c69d8a7c00 .

The leaky case (current `esl/master`): https://gist.github.com/RGafiyatullin/9cefce33bb22f3350cf0 .
The fixed case (current `RGafiyatullin/master`): https://gist.github.com/RGafiyatullin/4b895d6282b43d78dc42 .

Bits of reasoning:

* The mandatory `exml_event:free_parser/1` usage is not an option as it is a slightly less expected behaviour rather than a proper resource cleanup upon garbage collection. (The iodevices / ets's / dets's / you-name-it's usually get disposed upon the owner's termination ).

* `exml_event:free_parser/1` being bound to `exml_event:reset_parser/1` is IMHO a necessity since any attempt to use `exml_event:parse/2` with the resource being previously freed leads to a VM crash. The ErlangVM is not expected to crash with a segfault in case of a mistake in Erlang code.