OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [include/] [ustl/] [unew.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
 
6
#ifndef UNEW_H_11D237512B324C9C05A55DAF1BF086F1
7
#define UNEW_H_11D237512B324C9C05A55DAF1BF086F1
8
 
9
#include "uexception.h"
10
#include <stdlib.h>
11
 
12
/// Just like malloc, but throws on failure.
13
void* tmalloc (size_t n) throw (ustl::bad_alloc) __attribute__((malloc));
14
/// Just like free, but doesn't crash when given a NULL.
15
inline void nfree (void* p) throw() { if (p) free (p); }
16
 
17
#if WITHOUT_LIBSTDCPP
18
 
19
//
20
// These are replaceable signatures:
21
//  - normal single new and delete (no arguments, throw @c bad_alloc on error)
22
//  - normal array new and delete (same)
23
//  - @c nothrow single new and delete (take a @c nothrow argument, return
24
//    @c NULL on error)
25
//  - @c nothrow array new and delete (same)
26
//
27
//  Placement new and delete signatures (take a memory address argument,
28
//  does nothing) may not be replaced by a user's program.
29
//
30
inline void* operator new (size_t n) throw (ustl::bad_alloc)    { return (tmalloc (n)); }
31
inline void* operator new[] (size_t n) throw (ustl::bad_alloc)  { return (tmalloc (n)); }
32
inline void  operator delete (void* p) throw()                  { nfree (p); }
33
inline void  operator delete[] (void* p) throw()                { nfree (p); }
34
 
35
// Default placement versions of operator new.
36
inline void* operator new (size_t, void* p) throw() { return (p); }
37
inline void* operator new[] (size_t, void* p) throw() { return (p); }
38
 
39
// Default placement versions of operator delete.
40
inline void  operator delete  (void*, void*) throw() { }
41
inline void  operator delete[](void*, void*) throw() { }
42
 
43
#else
44
#include <new>
45
#endif  // WITHOUT_LIBSTDCPP
46
 
47
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.