Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!ntvaxb!larry From: larry@vaxb.acs.unt.edu Newsgroups: comp.lang.c++ Subject: turbo C++/malloc probelm Message-ID: <32729.26d49b87@vaxb.acs.unt.edu> Date: 24 Aug 90 03:14:15 GMT Lines: 37 I am using turbo c++ to write a game and I have run in to the following problem. I noticed that the values of one of the arrays I am using in my program were wrong for no obvious reason. Using the debugger, I stepped through the program, and found that the changes occured during a malloc. The code looks something like this. . [code omited] . int segarr[11][7]; . . . void *p0; void *p1; void *p2; unsigned int size; . . . size = imagesize(0,0,20,20); p0 = malloc(size); the segarr values change as soon as the malloc executes. After close inspection with the debugger, I noticed that the address of p0 was inside segarr. The problem is obvious, the solution is not. Oh, one other thing, the pointers p0,p1, and p2, are part of a class. Later........Larry ================================================================================ Larry Michalewicz Bitnet : LARRY@UNTVAX VAX Operator/Programmer THENET : NTVAXA::LARRY (and student of CSCI at) Internet : LARRY@VAXB.ACS.UNT.EDU The University of North Texas SPAN : UTSPAN::UTADNX::NTVAXA::LARRY ================================================================================