alanr@drutx.ATT.COM (RobertsonAL) (08/13/87)
In my version of Turbo C, the following program fails on several memory
models.
/*
* This program works correctly on the tiny, small, and medium models,
* but fails with the compact, large and huge models.
*/
main() {
char * junk1, *junk2;
junk1 = (char *)malloc(1000);
junk2 = (char *)malloc(1000); /* Malloc had better return new value*/
printf("junk1=%p, junk2=%p\n", junk1, junk2);
printf("%s\n", (junk1 == junk2 ? "OOPS." : "OK."));
}
This program writes OOPS under the circumstances described above. HOWEVER,
if you include <alloc.h>, then the problem goes away, because malloc isn't
properly declared to return a pointer (32 bits) instead of an int (default).
-- Alan Robertson
AT&T Information Systems
11900 N Pecos Room 31F-14
Denver, Colorado 80234
(303)-538-4796 drutx!alanr