Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Friday, March 31, 2006

double free an interface leads to serious error.

The following code leads to application error "The instruction at "0x00000000" referenced memory at "0x00000000". The memory could not be "read". and the error can't be caught by VC++ 8.0 although I am running module of debug version.
But it is detected by BoundsChecker 2005 after I rebuilt it with BoundsChecker enabled.

IErrorInfoPtr pEI = NULL; // must use native pointer, DON'T USE com smart pointer
if(SUCCEEDED((spER->GetErrorInfo (ulRecordNum, GetUserDefaultLCID(), &pEI))))
{
_com_error tmp_error(0, pEI, false); // "false" shall come with a native pointer
if(tmp_error.Description().length())
ts_tmp<<(LPCTSTR)tmp_error.Description()<<std::endl;
}
in fact the bad version is _com_error tmp_error(0, pEI);

Wednesday, March 29, 2006

float to datetime in SQLServer

output of the following are identical
select dbo.float2datetime(38804.619851774689)

select dbo.float2datetime(38804.619851774703+0.0000000134)

but 0.0000000135 would make difference

everyday life

Two cups of milk and one cup of coffee a day.
I read the description and found that there is fat in coffee:(