Elffuss BraidHub

kikocis/ncnn public

master · 1.7 KiBRawPermalink
1// Leo is pleased to support the open source community by making ncnn available.
2//
3// Copyright (C) 2018 Leo <leo@nullptr.com.cn>. All rights reserved.
4//
5// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
6// in compliance with the License. You may obtain a copy of the License at
7//
8// https://opensource.org/licenses/BSD-3-Clause
9//
10// Unless required by applicable law or agreed to in writing, software distributed
11// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12// CONDITIONS OF ANY KIND, either express or implied. See the License for the
13// specific language governing permissions and limitations under the License.
14
15#include "platform.h"
16
17#if NCNN_SIMPLESTL
18
19#include <stdlib.h>
20
21// allocation functions
22void* operator new(size_t size)
23{
24 return malloc(size);
25}
26
27void* operator new[](size_t size)
28{
29 return malloc(size);
30}
31
32// placement allocation functions
33void* operator new(size_t /*size*/, void* ptr)
34{
35 return ptr;
36}
37
38void* operator new[](size_t /*size*/, void* ptr)
39{
40 return ptr;
41}
42
43// deallocation functions
44void operator delete(void* ptr)
45{
46 free(ptr);
47}
48
49void operator delete[](void* ptr)
50{
51 free(ptr);
52}
53
54// deallocation functions since c++14
55#if __cplusplus >= 201402L
56
57void operator delete(void* ptr, size_t sz)
58{
59 free(ptr);
60}
61
62void operator delete[](void* ptr, size_t sz)
63{
64 free(ptr);
65}
66
67#endif
68
69// placement deallocation functions
70void operator delete(void* /*ptr*/, void* /*voidptr2*/)
71{
72}
73
74void operator delete[](void* /*ptr*/, void* /*voidptr2*/)
75{
76}
77
78extern "C" void __cxa_pure_virtual()
79{
80 NCNN_LOGE("[Fatal] Pure virtual func called, now exit.");
81 // do not abort here to avoid more unpredictable behaviour
82}
83
84#endif // NCNN_SIMPLESTL