osncore/osncore/src/osnnew.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  core functionality
       
    15 *
       
    16 */
       
    17 
       
    18 #include <stdlib.h>
       
    19 #include <stdexcept>
       
    20 #include <osn/osnnew.h> 
       
    21 
       
    22 // ---------------------------------------------------------------------------
       
    23 // Overloaded operator new.
       
    24 // ---------------------------------------------------------------------------
       
    25 //
       
    26 OSN_EXPORT void* operator new(size_t s,newarg) throw (std::bad_alloc)
       
    27     {
       
    28     void* any = malloc(s);
       
    29     if(!any)
       
    30     	{
       
    31     	throw std::bad_alloc();	
       
    32     	}
       
    33 
       
    34   	return any;	
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Overloaded operator delete.
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 OSN_EXPORT void operator delete(void* ptr,newarg) throw()
       
    42     {
       
    43     free(ptr);
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Overloaded operator new[].
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 OSN_EXPORT void* operator new[] (size_t s,newarg)throw (std::bad_alloc)
       
    51 	{
       
    52     void* any = malloc(s);
       
    53     if(!any)
       
    54     	{
       
    55     	throw std::bad_alloc();	
       
    56     	}
       
    57     	
       
    58    	return any;	
       
    59 	}	
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // Overloaded operator delete[].
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 OSN_EXPORT void operator delete[](void* ptr,newarg) throw()
       
    66 	{
       
    67  	free(ptr);	
       
    68 	}