diff: bug fix for io__tmpnam/5

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Feb 4 19:26:14 AEDT 1998


Fergus wrote:
> @@ -2677,7 +2677,7 @@
>  	if (tmp  == NULL) {
>  		fatal_error(""unable to create temporary filename"");
>  	}
> -	incr_saved_hp_atomic(LVALUE_CAST(Word *,FileName),
> +	incr_hp_atomic(LVALUE_CAST(Word *,FileName),
>  		(strlen(tmp) + sizeof(Word)) / sizeof(Word));
>  	strcpy(FileName, tmp);
>  	free(tmp);
> @@ -2695,7 +2695,7 @@
>  	struct stat buf;
>  
>  	len = strlen(Dir) + 1+ 5 + 3 + 1; /* Dir + / + Prefix + counter + \\0 
       */
> -	incr_saved_hp_atomic(LVALUE_CAST(Word *,FileName),
> +	incr_hp_atomic(LVALUE_CAST(Word *,FileName),
>  		(len + sizeof(Word)) / sizeof(Word));
>  	if (ML_io_tempnam_counter == 0)
>  		ML_io_tempnam_counter = getpid();

We should add a macro to mercury_string.h for use from within C code
that calls the right macro to allocate, makes sure that there is room
for the null byte and rounds up the size to a multiplie of the word size.

We could use it both here and in several other places in the library.

Zoltan.



More information about the developers mailing list