C allows casting from void * to other pointer types without an explicit cast. C++ requires the cast to compile.
-----Original Message----- From: Logan Shaw <[EMAIL PROTECTED]> Subj: Re: MemPtrFree Date: Mon Oct 10, 2005 1:14 am Size: 1K To: "Palm Developer Forum" <[email protected]> JAMES S HAINES wrote: > For some reason PODS 1.2 indicates an error via a red square in the upper > right hand corner of the editor whenever I try to release an unmovable chunk > of memory by MemPtrFree(p). Perhaps I'm using it incorrectly or perhaps a > bug in PODS?? I have included a function below as an example of where an > error occurs. > void calcPoint(double N, double E) > { > double Az,deg; > char *ptr, s[60]; > double distance; > > point.ptNum= (UInt16) StrAToI(fields[1]); > StrCopy(point.desc ,fields[2]); > DMSToDeg(fields[3],'-'); > StringToDouble(fields[4], &distance); > Az=BearToAz( deg, quad); > point.northing = N + distance * cos( Az / DinR); > ptr = MemPtrNew(64); > if (ptr) > { > DoubleToString( ptr, point.northing, decimal ); > FntSetFont( boldFont ); > WinSetUnderlineMode( noUnderline); > WinSetTextColor(red); > WinDrawChars(ptr,StrLen(ptr),71,99); > point.easting = E + distance * sin( Az / DinR ); > DoubleToString( ptr, point.easting, decimal ); > WinDrawChars( ptr,StrLen(ptr),71,112 ); > WinSetTextColor( black ); > //MemPtrFree (ptr); // error is here > } > return; > } When looking at that chunk of code, what I want to know is why it doesn't have an error on the "ptr = MemPtrNew(64);" line earlier than where you show it having an error. The reason is MemPtrNew()'s return type should be a "void *", and if so, the compile should take exception to your assigning it to "ptr", which is a "char *". The fact that it doesn't complain makes me wonder what's going on. On possibility is that somehow you have an improper definition of the "MemPtr" type. It should be a typedef to "void *" somewhere (like in the SDK header files). The fact that it isn't is making me wonder if perhaps you've accidentally defined MemPtr as something else somewhere. Or if perhaps some other file has mistakenly redefined (re-typedef-ed) MemPtr somewhere. - Logan -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
