]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - libc/bionic/new.cpp
Remove more BSD cruft from the public headers.
[android-sdk/platform-bionic.git] / libc / bionic / new.cpp
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
17 #include <errno.h>
18 #include <new>
19 #include <stdlib.h>
21 #include "private/libc_logging.h"
23 const std::nothrow_t std::nothrow = {};
25 void* operator new(std::size_t size) {
26     void* p = malloc(size);
27     if (p == NULL) {
28         __libc_fatal("new failed to allocate %zu bytes", size);
29     }
30     return p;
31 }
33 void* operator new[](std::size_t size) {
34     void* p = malloc(size);
35     if (p == NULL) {
36         __libc_fatal("new[] failed to allocate %zu bytes", size);
37     }
38     return p;
39 }
41 void  operator delete(void* ptr) throw() {
42     free(ptr);
43 }
45 void  operator delete[](void* ptr) throw() {
46     free(ptr);
47 }
49 void* operator new(std::size_t size, const std::nothrow_t&) {
50     return malloc(size);
51 }
53 void* operator new[](std::size_t size, const std::nothrow_t&) {
54     return malloc(size);
55 }
57 void  operator delete(void* ptr, const std::nothrow_t&) throw() {
58     free(ptr);
59 }
61 void  operator delete[](void* ptr, const std::nothrow_t&) throw() {
62     free(ptr);
63 }