Thread: Overloading operator new when a macro new is defined

  1. #1
    Registered User
    Join Date
    Mar 2011
    Location
    USA
    Posts
    2

    Question Overloading operator new when a macro new is defined

    [Mod Note: Split from here: "Non-function" error
    Please don't resurrect old threads. Instead, create a new one and put in a link to the old.]

    Not to bring up dead threads, but could you post code? I can't get the code to work, even when I moved the #define to be under the function.
    Last edited by CornedBee; 03-30-2011 at 03:27 PM.

  2. #2
    C++ Junkie Mozza314's Avatar
    Join Date
    Jan 2011
    Location
    Australia
    Posts
    174
    Quote Originally Posted by rjzak View Post
    Not to bring up dead threads, but could you post code? I can't get the code to work, even when I moved the #define to be under the function.
    Why would you want to use the code here with its dodgy macro tricks?

  3. #3
    Registered User
    Join Date
    Mar 2011
    Location
    USA
    Posts
    2
    Quote Originally Posted by Mozza314 View Post
    Why would you want to use the code here with its dodgy macro tricks?
    Because I've got a decent-sized project which exhibits some weird behaviour, so I'm sure there is a memory leak, but Valgrind and electric fence haven't been able to pin-point it. They show me stupid things like:

    by 0x402FDA: ??? (in /path/to/my/executable) - not helpful
    or
    by 0x4E3B522: ??? (in /usr/local/cuda/lib64/libcudart.so.3.2.16) - not helpful

    The dodgy code would show which new statements didn't have a corresponding delete. Simply and cleanly.

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    So do you still get the same error?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Valgrind will give you a line number if you compile with debugging enabled.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Linking problems in Visual Studio
    By h3ro in forum C++ Programming
    Replies: 5
    Last Post: 03-04-2008, 02:39 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. DLL compiling question
    By Noose in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2004, 07:16 AM