Originally Posted by
Frosttall
You know that I'm talking about C#, do you?
Yes... but I was just stating that it should not matter what language you are using.
I plan to use this for objects, for strings and for ints. I'll try it now but it seems like that it will work.
If you create a pointer to an integer, the location of that integer should never change unless you tell it to.
For example (using C code because its easiest),
Code:
int *x;
x = malloc(sizeof(int));
*x = 42;
int i;
//Assume the pointer x was allocated at memory location 0x0, the malloc call allocated memory at 0x4
//This should print the values 0 4 42
for(i=0;i<however_long_you_want);i++) printf("Address of x: %d Address of value stored in x: %d Value stored in x: %d \n", &x, x, *x);
x = malloc(sizeof(int));
//In C#, the garbage collector as I understand it will (on its next cycle) see that you no longer have a reference to the address at which 42 was stored, so it will free that memory.
*x = 400;
//Assume the garbage collector has not run yet however, so the memory at 0x4 still exists. The new address where the integer is stored is at 0x8
//This should print 0 8 400
for(i=0;i<however_long_you_want);i++) printf("Address of x: %d Address of value stored in x: %d Value stored in x: %d \n", &x, x, *x);
Unless I'm missing some fundamental difference that C# has over any other language I've programmed in (C,C++,C#,Java,Python,Delphi), there is no reason any of the values should be changing.
Now for example, if you are looking at memory within WoW instead of your own program, you may not have the base pointer. WoW (and all programs really) need to know where everything is, even if it is buried within tons of structures/classes.