Subject: | |
From: | |
Reply To: | |
Date: | Fri, 3 Oct 1997 07:22:31 +1000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
At 11:31 AM 1/10/97 PST8PDT, Bob Walker wrote:
>We just upgraded to MPE 5.5 Express2(from 5.0) on the weekend and
>now JTMAIL(by Jim Wowchuk) is now behaving strangly.
[snip...]
>gszLocalHost = getenv("HOST");
>ShowVars(1); /* debug - show all gsz.... variables if not NULL */
>gszMailHost = getenv("MAILHOST");
>ShowVars(2);
>gszMailPort = getenv("PORT");
>ShowVars(3);
>gszUser = getenv("MAILUSER");
>ShowVars(4);
I suspect that where in previous releases getenv() was allocated and
returned a pointer to a unique memory area, it is now returning a pointer to
a single static memory area.
Two suggestions to fix it.
1) Replace getenv() in the source with say jgetenv(), a local function:
char *jgetenv(char *env)
{
return strdup(getenv(env));
}
2) Replace each getenv() call in with a MACRO GETENV providing the same:
#define GETENV(a) strdup(getenv(a))
In both cases, you may need to create a strdup() function:
char *strdup(char *src)
{
char * tmp;
tmp = malloc(strlen(src) + 1);
strcpy(tmp, src);
return tmp;
}
or macro
#define strdup(a) strcpy(malloc(strlen(a) + 1), src)
Cheers.
----
Jim Wowchuk Vanguard Computer Services
_--_|\ Email: [log in to unmask]
/ \ Post: PO Box 18, North Ryde, NSW 2113
\_.--._/ <---Sydney NSW Phone: +61 (2) 9888-9688
v Australia Fax: +61 (2) 9888-3056
|
|
|