TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: ANTHONY TIBBS
date: 1998-03-04 19:49:00
subject: Strange allocation errors?

 * Crossposted from: (Fido) International C Programming Conference
I was attempting to allocate some memory today using another person's
system (running TC++ 3.0) using the following code:
#include 
#include 
#include 
int main (void)
{
char *x;
   printf ("Free mem=%ld\n", coreleft();
   /* In small memory model, this gives ~63.4k
      In large memory model, result is random (-4382 one time,
                                               4832382593 the next...) */
   x = (char *)malloc (20);
   if (!x)
   {
      printf ("Out of memory.");
      return 1;
   }
   /* In small memory model, x=ds:7436 (OK, this value changes)
      In large memory model, x=0000:0004 EVERY SINGLE TIME. */
   free (x);
   return 0;
}
Any idea what could be causing a pointer to 0000:0004 to be returned
on every single malloc()?
Take care,
Anthony Tibbs
... Blue Wave - World Tour - 1998
--- Blue Wave/DOS v2.30 [NR]
---------------
* Origin: The Tibbs' Point - Ottawa, ON, Canada - Pvt (1:163/215.38)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.