This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch libgfortran]: Fix build of libgfortran for mingw and improve POSIX ctime_r implementation


On Sat, Jan 29, 2011 at 5:57 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> recent changes lead to a build failure for mingw targets in gfortran.
> Following patch solves this.
>
> ChangeLog
>
> 2011-01-29 ?Kai Tietz
>
> ? ? ? ?* intrinsics/ctime.c (ctime_r): Improve implementation.
>
> Tested for x86_64-w64-mingw32. Ok for apply?
>
> Regards,
> Kai
>
> Index: intrinsics/ctime.c
> ===================================================================
> --- intrinsics/ctime.c ?(revision 169388)
> +++ intrinsics/ctime.c ?(working copy)
> @@ -42,11 +42,17 @@
>
>
> ?#ifndef HAVE_CTIME_R
> +/* Make sure we don't see here a macro. ?*/
> +#undef ctime_r
> +
> ?static char *
> ?ctime_r (const time_t * timep, char * buf __attribute__((unused)))
> ?{
> ?#ifdef HAVE_CTIME
> - ?return ctime (timep);
> + ?char *tmp = ctime (timep);
> + ?if (tmp)
> + ? ?tmp = strcpy (buf, tmp);
> + ?return tmp;

Note that this isn't any better than returning the statically allocated
result of ctime() (I suppose we don't free the result of ctime_r anywhere?).
So we now create memory leaks.  What's the problem with the original
implementation?

Richard.

> ?#else
> ? return NULL;
> ?#endif
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]