Forum OpenACS Development: Re: Win32-OpenACS Version 1.8

Collapse
Posted by Maurizio Martignano on
Dear Guastaf, the pleasure is mine.

Perhaps when you suggest the changes to the Aolserver community you could use the code here below, where the use of the function strlen has been optimized.

int i, str_len;
char *buf = _tempnam("/tmp", "nsd");

if (buf == NULL) {
Tcl_SetResult(interp, "could not generate temporary filename.", TCL_STATIC);
return TCL_ERROR;
}
/*
Change back slash characters into slash characters
*/
str_len = strlen(buf);
for (i = 0; i < str_len; i++) {
if (buf[i] == '\\') buf[i] = '/';
}
/*
The documentation says that _tempnam() allocates memory via
malloc(); to be sure, that the "right" free() is used, we do
not use TCL_DYNAMIC but the TCL_VOLATILE followed by the manual
free().
*/
Tcl_SetResult(interp, buf, TCL_VOLATILE);
free(buf);

Once again many thanks,
Maurizio