From: eric e. <eri...@gm...> - 2005-05-18 13:40:20
|
On 5/18/05, Plamen Neykov <Pla...@re...> wrote: >=20 > Hi Eric, >=20 > I've took a look where the TempStr function is used - it comes predominan= tely > in the generated code - qladdin.cpp, I found only one reference elsewhere= - > in the file xlutils.cpp. I think the python generaton procedure could be > easily changed in the way to generate in the first byte of a string liter= al > the size of it directly so that this doesn't have to be done run-time - I > could try to change it - what do you think? >=20 > Thanks, > Plamen Hi Plamen, Here's a revised TempStr function which should do the trick: LPXLOPER TempStr(LPSTR lpstr) { LPXLOPER lpx; lpx =3D (LPXLOPER) GetTempMemory(sizeof(XLOPER)); if (!lpx) { return 0; } /* lpstr[0] =3D (BYTE) lstrlen (lpstr+1); lpx->xltype =3D xltypeStr; // lpx->val.str =3D (PUCHAR) lpstr; lpx->val.str =3D lpstr; */ int len =3D strlen(lpstr); lpx->xltype =3D xltypeStr; lpx->val.str =3D GetTempMemory(len); if (!lpx->val.str) return 0; strncpy(lpx->val.str, lpstr, len); lpx->val.str[0] =3D (BYTE) len-1; return lpx; } But your proposed solution is much preferable: - faster - no risk of exceeding available temp memory - no VC7-specific hack so if you're happy to implement that it would be hugely appreciated. Regards, Eric |