Mail Archives: cygwin/1998/04/18/05:32:39
I am trying to port ingres. Somebody done it before?
Ingres is originally written for DEC PDP, maybe the location of stack
and heap are reveresed there.
I have probems with this piece of code:
xfree(cp)
char *cp;
{
extern end; /* break (II) */
register char *lcp, *lend, *lacp;
lcp = cp;
lacp = (char *)&cp;
lend = (char *)&end;
if (lcp >= lend && lcp < lacp) /* make sure its in heap */
{
free(lcp);
return (0);
}
return (1);
}
"end" results in link-error, but even if I create "end" somewhere on
the heap the if-statement looks wrong: I checked it with this code:
#include <iostream.h>
char* end;
void f(char* cp)
{
cout << "adres end: " << (void*)end << endl;
cout << "adres stack: " << (void*)&cp << endl;
if ((void*)end < (void*)&cp)
cout << "heap lower than stack" << endl;
else cout << "heap higher than stack" << endl;
}
int main()
{
char c;
end = new char;
f(&c);
delete end;
return 0;
}
Output: "heap higher than stack".
Is it true that stack and heap are reversed in PDP?
What happens when I replace xfree() by free(), I mean: is it
really harmless to free something not allocated on the heap? free()
in next program doesn't do anything.
#include <stdlib.h>
int main()
{
char* s = "The string\n";
printf("%s", s);
free (s);
printf("%s", s);
return 0;
}
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -