free() in malloc.c

Till Straumann strauman at slac.stanford.edu
Wed Nov 8 18:25:04 UTC 2006


Kate Feng wrote:
> Does the following patch make sense since the free(void *ptr)
> of malloc.c checks for the   :
>
>   
>> if ( !ptr )
>>  return;
>>     
>
> It  seems that ptr is not reset to zero by the OS if
> free() is successful.   I thought it's better to have
> the OS to reset the ptr to be zero if free() is successful.
> What do you think ?  Kate
>   
??

'ptr' is passed by value

T.
> diff -c -u cpukit/libcsupport/src/malloc.c.orig
> cpukit/libcsupport/src/malloc.c
>
> --- cpukit/libcsupport/src/malloc.c.orig Thu May 25 13:36:31 2006
> +++ cpukit/libcsupport/src/malloc.c Fri Nov  3 12:49:37 2006
> @@ -496,6 +496,8 @@
>      errno = EINVAL;
>      assert( 0 );
>    }
> +  else
> +    ptr = 0;
>  }
>
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list