[m-rev.] diff: get system building under cygwin and mingw
Peter Ross
pro at missioncriticalit.com
Wed Nov 29 11:35:56 AEDT 2006
On 11/28/06, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>
> On Tue, 28 Nov 2006, Peter Ross wrote:
>
> > Index: runtime/mercury_runtime_util.c
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/runtime/mercury_runtime_util.c,v
> > retrieving revision 1.4
> > diff -U5 -r1.4 mercury_runtime_util.c
> > --- runtime/mercury_runtime_util.c 14 Nov 2006 00:15:41 -0000 1.4
> > +++ runtime/mercury_runtime_util.c 28 Nov 2006 06:47:03 -0000
> > @@ -83,5 +83,38 @@
> > fprintf(stderr, "Mercury runtime: error in call to atexit: %s\n",
> > strerror(errno));
> > exit(EXIT_FAILURE);
> > }
> > }
> > +
> > +#if ! defined(MR_HAVE_PUTENV) && defined(MR_HAVE__PUTENV)
> > + #define putenv _putenv
> > +#endif
> > +
> > +int
> > +MR_setenv(const char *name, const char *value, int overwrite)
> > +{
> > +#if defined(MR_HAVE_SETENV)
> > + return setenv(name, value, overwrite);
> > +#elif defined(MR_HAVE_PUTENV) || defined(MR_HAVE__PUTENV)
> > + char *env;
> > + int length;
> > +
> > + if (!overwrite && getenv(name) != NULL) {
> > + return 0;
> > + }
> > +
> > + length = strlen(name) + strlen(value) + 2;
> > + env = MR_NEW_ARRAY(char, length);
> > +
> > + env[0] = '\0';
> > + strcat(env, name);
> > + strcat(env, "=");
> > + strcat(env, value);
> > +
> > + MR_free(env);
> > +
> > + return putenv(env);
>
> You're using that memory after you've freed it. Rewrite as:
>
What makes it even more embarrassing is that I thought about that at
the time. Woops!
Fixed now.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list