ref count the linreg structure so as to avoid double free problems