Added helper functions: lrlib_safe_free() and lrlib_safe_free_and_null()