• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

##### Share on other sites
If you want thread-safe, you could use CRITICALSECTION or mutexes.

##### Share on other sites

Don''t listen to me. I''ve had too much coffee.

##### Share on other sites
on MSDN, do a search on "the operator delete function" -thats the article title...

delete takes a void pointer.. *duh*
void delete[](void* vp){}

[edited by - evilcrap on July 29, 2002 11:41:05 AM]

##### Share on other sites
I''m kinda curious, how are you compiling C++ code for the GBA? I didn''t think a C++ compiler was available for it...

I would just overload the global new & delete, set the nmi (non-maskable interupt) bit in the GBA and call into malloc & free. That assumes there''s no virtual memory to deal with (unless they also added harddrives and a protected mode to the GBA...)

##### Share on other sites
quote:
Original post by DerekSaw
If you want thread-safe, you could use CRITICALSECTION or mutexes.

Ooops.. I miss that ''GBA'' thingie. Sorry.

##### Share on other sites
quote:
I''m kinda curious, how are you compiling C++ code for the GBA? I didn''t think a C++ compiler was available for it...

Have a look at   http://www.io.com/~fenix/devkitadv/or     http://www.ngine.de/ham.html

Right now I do this (well, thanks everybody, overloading ''delete'' did work) :

  void* operator new(size_t s) throw() {   DISABLE_THREAD_SWITCHING();   void *p = malloc(s);   RESTORE_THREAD_SWITCHING();   return p;}void operator delete(void* p) throw() {  DISABLE_THREAD_SWITCHING();  free(p);  RESTORE_THREAD_SWITCHING();}

Do you know if this code works correctly for all klasses and virtual classes, virtual destructors, etc. ?

I still have a problem with the std::list etc.: they use the default ''new'' and ''delete'' even when I overload (/override ) them (perhaps some strange macro or #include? or allocator?? I really don''t no much about allocators ) - does anyone know if one can make the std-libraries to use my own new/delet ?

##### Share on other sites
quote:
Original post by LeoMaheo
I still have a problem with the std::list etc.: they use the default ''new'' and ''delete'' even when I overload (/override ) them (perhaps some strange macro or #include? or allocator?? I really don''t no much about allocators ) - does anyone know if one can make the std-libraries to use my own new/delet ?

Most implementations of STL do far out, freaky things with macros and system functions, with the result that they probably never even bother to call a function called "new".

The easiest, and most Right Way to do this, is to write your own custom allocator. It''s surprisingly painless. Check the STL docs.

Don''t listen to me. I''ve had too much coffee.

• ### Forum Statistics

• Total Topics
628285
• Total Posts
2981836

• 10
• 10
• 10
• 11
• 17