#3669 - daveb - Tue Mar 04, 2003 7:34 pm
Hello all,
Using g++I am creating an object using new. In the constructor I am assigning the member variables, but if I examine them the values are corrupt. The code previously worked and testing the same code in visual c causes no problems.
My guess is, new is returning a restricted (&volatile?) area of the GBAs memory and so the object is corrupt.
Is there a way to ensure that the restriced parts of the GBAs memory are not overwritten?
Sorry if this is an obvious question or has been covered before.
thanks
david
#3670 - Vortex - Tue Mar 04, 2003 8:00 pm
The new operator uses some form of alloc() to allocate memory on the heap. My suggestion is to try the following things:
1. Create a very simple C program using malloc(): void *p = malloc(...);
Print which memory location the poinet points to. Compare the value with the GBAs memory map
2. Try to figure out where your heap is allocated and is there enought space for your allocated objects.
Hope that helps
#3672 - Paul Shirley - Tue Mar 04, 2003 9:07 pm
removed
Last edited by Paul Shirley on Sun Mar 28, 2004 9:49 pm; edited 1 time in total
#3694 - daveb - Wed Mar 05, 2003 12:15 pm
Thanks for your replies.
My code is like this. This code worked previously until I built up another class.
...
object f*
f = new object;
printf("f = %d",f); // output was 12394656 using visual boy sdl
...
object::object()
{
membervalue = 4;// type s16
printf("member value = %d",membervalue); //output was -498401148
}
How can I tag all my values as EWRAM? - Paul, I cant find your previous post.
Also how can I determine where in memory 12394656 actually is.
Is there some sort of tutorial for programming within the gba memory? Although I have some C++ experience I have no knowledge of working with fixed areas of memory.
Again thanks,
david
#178255 - Dwedit - Sun Nov 09, 2014 7:19 pm
Reference counting is where it's at. Then you never need to use new or delete ever again.
For an example, see http://wehlou.com/Code/Rcptr/ (The .exe file is a winzip self extractor containing a Visual C++ 6 project)
The code may be from 2001, but that's fine.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#178273 - gauauu - Mon Nov 17, 2014 5:02 pm
SimonB wrote: |
Nice bump, almost 12 years later...:P
Simon |
Pretty sure this is attempts at spam. All these new accounts have a single word in their sig (which is probably supposed to be a spam link) and are bumping dead threads.
We need some mods to swoop in and kill them :) (Simon, are you the only moderator that's still around?)
#178277 - SimonB - Thu Nov 20, 2014 5:09 pm
*Swooping*
:=)
Simon
#178278 - SimonB - Thu Nov 20, 2014 5:20 pm
http://forum.gbadev.org/viewtopic.php?p=178250&highlight=#178250
See that thread. It started with that user, but he had a much more human/relevant post. I dont remember seeing that spam URL in his signature before, so it was probably changed later, after you replied.
Then 3 spam-bots followed, all with IP's from Pakistan (like the original adson3492) and with gmail.com e-mail adresses and one word signatures.
The first of the spam-bots had the word "adson" as his signature (note the first "human" spam-bots nickname....adson3492).
Oh well, they have been deleted now :=) (will delete adson3492 in a day or so)
Simon
#178280 - gauauu - Fri Nov 21, 2014 8:43 pm
Thanks!