Use erealloc in toolkit_import_register().
Replace malloc/free/calloc/realloc/strdup/strndup with their error-checking variants in the client code.
Avoid freeing NULL pointer when deinitialising mplayer widget.