Fix memory leaks by rewriting engine init/finish logic

Currently, some memory and indices were allocated by the engine
during the binding, but this means the resources would leak if
the engine is unloaded again. Instead, refactor the initialization
code to use the bound init() and finish() functions, so resources
are allocated in init() and can be freed again in finish().

This makes valgrind happy.

Signed-off-by: Jonathan Wernberg <jonathaw@axis.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
5 files changed