[tstr] bugfix - uninitialized value
[scan] add the ability to make the scan object hold the reference to the buffer, and detroy it on scan_free
[scan] bugfix - function constructor provides a copy to the scan, the scan must destroy it on exit