Re: ESQL and Internal Date Conver Weird Prob.
Posted in 1998
Robert Ogren <rmogren@gte.net> asked: >Well I went back and cast it to the value which rdatestr wants >(long (*colptr->sqldata)) still blows up in the malloc of rdatestr. Not quite! You must cast the sqldata pointer into a long pointer, and then dereference the long pointer. That's not what you've written; you've dereferenced the char pointer (obtaining a char) and then coerced the char into a long. Assuming you have allocated the memory correctly, then you should use: *((long *)colptr->sqldata) Since you are still core dumping, I suspect that colptr->sqldata is not properly allocated. Or, the trouble may be elsewhere. Since it is a malloc blowing up on you, something, somewhere, is incorrectly trampling on allocated memory -- the best tool for the job of tracking down such problems is Purify! If you aren't sure about SQLDA memory allocation, consider retrieving SQLCMD from the IIUG archives (http://www.iiug.org), and study the code in describe.ec, which does the job. And you can find code with a similar idiom for dereferencing the SQLDA structure elsewhere in the code for SQLCMD. Yours, Jonathan Leffler (jleffler@informix.com) #include <disclaimer.h> >strange, I've skipped the call for now, will look at again later when I'm not >ticked off at it. > >Mike Segel wrote: >> Robert Ogren wrote: >> > Having a strange problem show up when trying to access the a column >> > with the type DATE. Any help is appreciated, I am probably >> > overlooking something but just don't see it. >> > SIGSEGV ---> rdatestr((long)colptr->sqldata,ptrEcell->omc); >> >> Just a hunch, it looks like it dies when it calls this function. >> Whats the prototype look like? And since it dies at the call, >> are you sure you're passing a pointer or the value?