Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

59 lines
1005 B

//***************************************************************************
//
// NewThrow.CPP
//
// Module: Common new/delete w/throw
//
// Copyright (c) 1998-2001 Microsoft Corporation, All Rights Reserved
//
//***************************************************************************
#include <windows.h>
#include <malloc.h>
#include <provexce.h>
void* __cdecl operator new( size_t n)
{
void *ptr = malloc( n );
if (!ptr)
{
throw CHeap_Exception(CHeap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
}
return ptr;
}
void* __cdecl operator new[]( size_t n)
{
void *ptr = malloc( n );
if (!ptr)
{
throw CHeap_Exception(CHeap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
}
return ptr;
}
void __cdecl operator delete( void *ptr )
{
if (ptr)
{
free( ptr );
}
}
void __cdecl operator delete[]( void *ptr )
{
if (ptr)
{
free( ptr );
}
}