ncnn

Форк
0
/
simplestl.cpp 
84 строки · 1.7 Кб
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
22
void* operator new(size_t size)
23
{
24
    return malloc(size);
25
}
26

27
void* operator new[](size_t size)
28
{
29
    return malloc(size);
30
}
31

32
// placement allocation functions
33
void* operator new(size_t /*size*/, void* ptr)
34
{
35
    return ptr;
36
}
37

38
void* operator new[](size_t /*size*/, void* ptr)
39
{
40
    return ptr;
41
}
42

43
// deallocation functions
44
void operator delete(void* ptr)
45
{
46
    free(ptr);
47
}
48

49
void operator delete[](void* ptr)
50
{
51
    free(ptr);
52
}
53

54
// deallocation functions since c++14
55
#if __cplusplus >= 201402L
56

57
void operator delete(void* ptr, size_t sz)
58
{
59
    free(ptr);
60
}
61

62
void operator delete[](void* ptr, size_t sz)
63
{
64
    free(ptr);
65
}
66

67
#endif
68

69
// placement deallocation functions
70
void operator delete(void* /*ptr*/, void* /*voidptr2*/)
71
{
72
}
73

74
void operator delete[](void* /*ptr*/, void* /*voidptr2*/)
75
{
76
}
77

78
extern "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
85

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.