Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Overloaded global operator new  (Read 5901 times)

0 Members and 1 Guest are viewing this topic.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Overloaded global operator new
« Reply #15 on: January 20, 2010, 12:02:50 am »
Ok. So no problem there :D
Laurent Gomila - SFML developer

Flawe

  • Newbie
  • *
  • Posts: 24
    • View Profile
Overloaded global operator new
« Reply #16 on: January 20, 2010, 10:58:26 am »
I had a quick look at the SFML code (kudos on the standard by the way, very clean!) but I couldn't see anything strange happening.

I have a call to sf::Shape::Circle that returns a Shape by value. The shape contains the std::vector with all the points, which is copied with its operator=. The problem lies with the call to deallocate() which seems to trigger my operator delete. This is because I have the following code:

Code: [Select]

class A {
    A();
    sf::Shape s;
};

A() {
    s = sf::Shape::Circle( ... );
}


The deallocate on the std::vector inside sf::Shape is called on s, since the operator= from above will have to delete the old vector which contains the point added to sf::Shape in its constructor (representing the center of the shape). The only thing I can think of is that the sf::Shape constructor is called before my operator new is linked into the translation unit, but that doesn't make sense.