Deprecate SETPTR macro from plugin API

* It's name is non-obvious and being a macro it might have weird
side-effects. We shouldn't encourage plugins to use this.
* Add compatible macro UTILS_REPLACE_PTR which uses an inline function
call to avoid the issues of macros, for use in core-code only, not
part of plugin API.
* Replace all uses of SETPTR with UTILS_REPLACE_PTR in core code.
* Replace all uses of SETPTR in plugins with normal C code. I think
this even plugs a leak or two and fixes some locale vs UTF8 filename
issues.