Add sanity check when freeing resources

Check if module has patterns, tracks, instruments or samples before
releasing the corresponding allocated data.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
Better handling for load errors

We must call xmp_release_module() to clean up after load errors, so we
can't expect a XMP_STATE_LOADED state when we release.

Also in case of load errors, the module is not scanned, so test for
scan counter allocation before freeing.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>