From: GAMMELJL AT SLU DOT EDU Date: Thu, 16 Sep 1999 11:29:13 -0500 (CDT) Subject: Problem with new malloc To: djgpp AT delorie DOT com Message-id: <01JG1BRFCFYQ8WYLEP@SLU.EDU> Organization: SAINT LOUIS UNIVERSITY St. Louis, MO X-VMS-To: IN%"djgpp AT delorie DOT com" MIME-version: 1.0 Reply-To: djgpp AT delorie DOT com // I am having a problem with the new malloc.c. //When one uses the new malloc.c via the include statement //at MARK below the program compiles but does not run. When one //removes the include statement, the program uses the old malloc //(? malloc.h located in c:\djgpp\include), compiles and runs properly. //Note: The new malloc.c may reside in some other directory //than c:\djgpp\src\libc\stdlib on your machine (or, by now, it //may be part of the Delorie distribution of its //port of gnu to DOS, in which case you may not have the //old malloc) //The problem occurs only in connection with overloading an operator //(such as +) to define how + applies to the members of a user //defined class (zvector in the example below). //Of course, it is possible that I am making some other error. //If so, please tell me. #include #include #include #include #include //#include "c:\djgpp\src\libc\ansi\stdlib\malloc.c" //MARK const int length=10; const int lengthpad=length+0xa; //padding in memory allocation class zvector { public: unsigned int *s; zvector(); ~zvector(); }; zvector::zvector() //constructor for realmp {s = new unsigned int [lengthpad];} zvector::~zvector() //destructor for realmp {delete[] s;} zvector e; zvector f; zvector g; zvector w1; zvector w8; zvector w9; extern zvector operator+(zvector w8,zvector w9); zvector operator+(zvector w8,zvector w9) { int zi; for (zi=1;zi