http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pointing to the wrong thing......




   Hello all,

   I have once again run into another memory type problem. This one really 
has me running up walls. Heres the scenario: I have created this function 
which preforms operations on 4 pararmeters ( more specifically, it scans the 
edge of a polygon and store as the points in an array ). After this is 
completed, I have the function return a pointer to the beggining of the 
array. Sorta like this:

int* _doStuff(int a, int b, int c, int d)
{
   int* results;

   // do some stuff here to initalize the members of results.....

   return results;
}

That works out as planned, and I get a address from which I can refrence the 
data. The problem is, I  have another function that calls this function. 
Sorta like:

void _doSomeMoreStuff(void)
{
   int* a;
   int* b;
   int* c;

   a = _doStuff(x,x,x,x);
   b = _doStuff(x,x,x,x);
   c = _doStuff(x,x,x,x);

   // more things go on down here.....
}

That works sorta as planned... The sorta is on account that a,b, and c all 
point to the same memory location!!! I have been having the the function log 
stuff to a file and here is a sample:

edge1 @ 4F46:0004 = x = 20 y = 90
edge2 @ 4F46:0004 = x = 20 y = 90
edge3 @ 4F46:0004 = x = 20 y = 90

edge1 @ 4F46:000A = x = 20 y = 89
edge2 @ 4F46:000A = x = 20 y = 89
edge3 @ 4F46:000A = x = 20 y = 89

edge1 @ 4F46:0010 = x = 20 y = 88
edge2 @ 4F46:0010 = x = 20 y = 88
edge3 @ 4F46:0010 = x = 20 y = 88

edge1 @ 4F46:0016 = x = 20 y = 87
edge2 @ 4F46:0016 = x = 20 y = 87
edge3 @ 4F46:0016 = x = 20 y = 87

   I hope that someone will be able to assist me in this regard. And as 
always, I am willing to provide exact source if it will be of help.

  Josiah Avery
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html