⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 new.mh

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 MH
字号:
///////////////////////////////////////////////////////////////////////////
// FILE: new/new.h (Dynamic memory support)
//
:keep CPP_HDR
:include crwat.sp
//
// Description: This header is part of the C++ standard library.
///////////////////////////////////////////////////////////////////////////
:segment !CNAME
#ifndef _NEW_H_INCLUDED
#define _NEW_H_INCLUDED

:include readonly.sp

#ifndef _NEW_INCLUDED
  #include <new>
#endif
:: No using declarations here. <new.h> exists only to support legacy
:: programs. Thus access to new features (like std::bad_alloc) via
:: <new.h> is not provided.

#endif
:elsesegment
#ifndef _NEW_INCLUDED
#define _NEW_INCLUDED

:include readonly.sp

#ifndef __cplusplus
#error The header new requires C++
#endif

#ifndef _COMDEF_H_INCLUDED
  #include <_comdef.h>
#endif

#ifndef _STDDEF_H_INCLUDED
  #include <stddef.h>
#endif

#ifndef _EXCEPTION_INCLUDED
  #include <exceptio>
#endif

:include cpppfv.sp

extern void *operator new( size_t );
extern void *operator new( size_t, void * );
extern void *operator new []( size_t );
extern void *operator new []( size_t, void * );
extern void operator delete( void * );
extern void operator delete []( void * );
_WPRTLINK extern PFV set_new_handler( PFV );
_WPRTLINK extern PFU _set_new_handler( PFU );
:segment !QNX
#if defined(__SW_BR)
  _WPRTLINK extern _PUP _set_op_new( _PUP );
  _WPRTLINK extern _PUP _set_op_new_array( _PUP );
  _WPRTLINK extern _PVV _set_op_delete( _PVV );
  _WPRTLINK extern _PVV _set_op_delete_array( _PVV );
#endif
:endsegment

// NOTE: Open Watcom currently does not throw std::bad_alloc on
// allocation failures. This class is defined here to so that programs
// that reference it will at least compile. Consider this a first step
// in building an exception throwing implementation of operator new.

namespace std {
  class bad_alloc : public exception {
  public:
    bad_alloc( ) _WCTHROWS() :
      exception( "unable to allocate memory" ) { }

    bad_alloc( const bad_alloc & ) _WCTHROWS() { }

    bad_alloc & operator=( bad_alloc & ) _WCTHROWS()
        { return *this; }

    virtual ~bad_alloc( ) _WCTHROWS() { }
  };
}

#endif
:endsegment

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -