overridding new and delete operators



Hi - I have a question regarding override of new and delete in visual studio
..NET 2003

I have overriden the operators globally as follows, as I have code which
expects NULL to be returned when memory fails to be allocated rather than
catching an exception

My question is do I also need to override new[] and delete[]. It looks as
though the compiler is already generating calls to my new and delete
functions.
//

// Function : operator new OVERRIDE

//

// Purpose : Override the "throwing" new operator

// : to make it return NULL on failure.

//

// Returns : void*

//

// Parameter : size_t size

//

void *__cdecl operator new(size_t size) _THROW1(std::bad_alloc)

{

void* pAlloc = malloc(size);

return pAlloc;

}





//

// Function : operator delete OVERRIDE

//

// Purpose : Override delete to free memory

// : allocated by the new override.

//

// Returns : void

//

// Parameter : none

//

void __cdecl operator delete(void* pAlloc) _THROW0()

{

free(pAlloc);

}



Many Thanks

Paul G


.



Relevant Pages

  • Re: Partially overriding a method?
    ... It will help you see that a method either does or does not override another. ... public static void main{ ... class SubClass extends MainClass { ... DoesItOverride doesIt = new Rider; ...
    (comp.lang.java.programmer)
  • .NET 3.5
    ... You will need to define this event by yourself - override the DropDownList: ... protected virtual void OnDblClick ... Jeff User wrote: ... selection in a listbox and have it postback to server. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How to bind JTable and data in a text file ?
    ... NetBeans protected code, ... public static void main{ ... public String fileName, fileID, personName; ...
    (comp.lang.java.programmer)
  • Re: Inheritance design quandry
    ... public static void DoSomething() ... You cannot override static methods; since you don't have an instance, ... will have to create a metaclass that can be assigned to a variable and who's ... internal protected Metaclass() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Inheritance design quandry
    ... "I need to override a static method which happens to be referenced by ... public static void DoSomething() ... public class Metaclass ... internal protected Metaclass() ...
    (microsoft.public.dotnet.languages.csharp)