sl@0: /* sl@0: * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(- * * ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * Name : new sl@0: * Part of : standard c++ library. sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef _SYMCPP_NEW_H_ sl@0: #define _SYMCPP_NEW_H_ sl@0: sl@0: sl@0: #ifndef _STLP_FEATURES_H sl@0: # include sl@0: #endif sl@0: sl@0: sl@0: sl@0: # ifdef __EABI__ sl@0: # include //Include the STLP internal header to make macros/typedefs expected of available. sl@0: # define _STLP_CSTDDEF //Define this macro so that doesn't get included by new_eabi.h sl@0: sl@0: #include "exception" sl@0: sl@0: namespace std sl@0: { sl@0: typedef unsigned size_t; sl@0: sl@0: class bad_alloc : public exception sl@0: { sl@0: public: sl@0: IMPORT_C bad_alloc() __NO_THROW; sl@0: IMPORT_C bad_alloc(const bad_alloc&) __NO_THROW; sl@0: IMPORT_C bad_alloc& operator=(const bad_alloc&) __NO_THROW; // { return *this;} sl@0: sl@0: IMPORT_C virtual ~bad_alloc() __NO_THROW; // {} sl@0: IMPORT_C virtual const char* what() const __NO_THROW; // { return "bad_alloc";} sl@0: }; sl@0: sl@0: struct nothrow_t {}; sl@0: extern const nothrow_t nothrow; sl@0: sl@0: typedef void (*new_handler)(); sl@0: sl@0: IMPORT_C new_handler set_new_handler(new_handler) __NO_THROW; sl@0: } sl@0: sl@0: // Single-object form sl@0: sl@0: IMPORT_C void* operator new(std::size_t) __THROW(std::bad_alloc); sl@0: IMPORT_C void operator delete(void*) __NO_THROW; sl@0: sl@0: IMPORT_C void* operator new(std::size_t, const std::nothrow_t&) __NO_THROW; sl@0: IMPORT_C void operator delete(void*, const std::nothrow_t&) __NO_THROW; sl@0: sl@0: #ifndef __PLACEMENT_NEW_INLINE sl@0: #define __PLACEMENT_NEW_INLINE sl@0: inline void* operator new(std::size_t, void* p) __NO_THROW sl@0: { sl@0: return p; sl@0: } sl@0: sl@0: inline void operator delete(void*, void*) __NO_THROW sl@0: { sl@0: } sl@0: #endif sl@0: sl@0: // Array form sl@0: sl@0: IMPORT_C void* operator new[](std::size_t) __THROW(std::bad_alloc); sl@0: IMPORT_C void operator delete[](void*) __NO_THROW; sl@0: sl@0: IMPORT_C void* operator new[](std::size_t, const std::nothrow_t&) __NO_THROW; sl@0: IMPORT_C void operator delete[](void*, const std::nothrow_t&) __NO_THROW; sl@0: sl@0: #ifndef __PLACEMENT_VEC_NEW_INLINE sl@0: #define __PLACEMENT_VEC_NEW_INLINE sl@0: inline void* operator new[](std::size_t, void* p) __NO_THROW sl@0: { sl@0: return p; sl@0: } sl@0: sl@0: inline void operator delete[](void*, void*) __NO_THROW sl@0: { sl@0: } sl@0: #endif sl@0: sl@0: // Symbian additions (not part of standard C++). sl@0: IMPORT_C void* operator new(std::size_t, std::size_t) __NO_THROW; sl@0: IMPORT_C void operator delete(void*, std::size_t) __NO_THROW; sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: # else sl@0: # include sl@0: # include sl@0: # include sl@0: namespace std { sl@0: sl@0: struct nothrow_t { }; sl@0: extern const nothrow_t nothrow; sl@0: sl@0: class bad_alloc : public exception { sl@0: public : sl@0: bad_alloc () __NO_THROW {}; sl@0: bad_alloc ( const bad_alloc &) __NO_THROW {}; sl@0: bad_alloc & operator =( const bad_alloc &) __NO_THROW { return *this;} sl@0: virtual const char * what () const __NO_THROW { return "bad_alloc";} sl@0: }; sl@0: sl@0: typedef void (* new_handler )(); sl@0: new_handler set_new_handler ( new_handler new_p ) __NO_THROW; sl@0: } sl@0: sl@0: IMPORT_C void* operator new (std::size_t) __THROW(std::bad_alloc); sl@0: IMPORT_C void operator delete (void*) __NO_THROW; sl@0: sl@0: IMPORT_C void* operator new (std::size_t, const std::nothrow_t&) __NO_THROW; sl@0: IMPORT_C void operator delete (void*, const std::nothrow_t&) __NO_THROW; sl@0: sl@0: IMPORT_C void* operator new[] (std::size_t) __THROW(std::bad_alloc); sl@0: IMPORT_C void operator delete[] (void*) __NO_THROW; sl@0: sl@0: IMPORT_C void* operator new[] (std::size_t, const std::nothrow_t&) __NO_THROW; sl@0: IMPORT_C void operator delete[] (void*, const std::nothrow_t&) __NO_THROW; sl@0: sl@0: # ifndef __PLACEMENT_NEW_INLINE sl@0: # define __PLACEMENT_NEW_INLINE sl@0: inline void* operator new(std::size_t, void* aBase) __NO_THROW sl@0: {return aBase;} sl@0: sl@0: inline void operator delete(void*, void*) __NO_THROW {} sl@0: # endif //__PLACEMENT_NEW_INLINE sl@0: sl@0: # ifndef __PLACEMENT_VEC_NEW_INLINE sl@0: # define __PLACEMENT_VEC_NEW_INLINE sl@0: inline void* operator new[](std::size_t, void* aBase) __NO_THROW sl@0: {return aBase;} sl@0: sl@0: inline void operator delete[](void* , void*) __NO_THROW {} sl@0: # endif //__PLACEMENT_VEC_NEW_INLINE sl@0: sl@0: # endif //__EABI__ sl@0: #endif //_SYMCPP_NEW_H_