Under all systems I known, tempnam returns a pointer to newly allocated memory if
the first parameter is 0. Under djgpp 2.01 tempnam behaves the same as tmpnam
which returns a pointer to a static memory which is overwritten after each call
to tmpnam.
The following program illustrates the bug;
#include <iostream.h>
#include <stdio.h>
int main()
{
char * p1 = tempnam(0,"t1");
char * p2 = tempnam(0,"t2");
cout << p1 << " " << p2 << endl;
};
Normally one gets two different values whereas under
djgpp 2.01 p1 and p2 are the same.
I also looked at the sources and found:
char *
tempnam(const char *_dir, const char *_prefix)
{
return tmpnam(0);
}
A correct approximation based on tmpnam would be
return strdup(tmpnam(0));