You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

simplestl.cpp 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include "platform.h"
  15. #if NCNN_SIMPLESTL
  16. #include <stdlib.h>
  17. // allocation functions
  18. void* operator new(size_t size)
  19. {
  20. return malloc(size);
  21. }
  22. void* operator new[](size_t size)
  23. {
  24. return malloc(size);
  25. }
  26. // placement allocation functions
  27. void* operator new(size_t /*size*/, void* ptr)
  28. {
  29. return ptr;
  30. }
  31. void* operator new[](size_t /*size*/, void* ptr)
  32. {
  33. return ptr;
  34. }
  35. // deallocation functions
  36. void operator delete(void* ptr)
  37. {
  38. free(ptr);
  39. }
  40. void operator delete[](void* ptr)
  41. {
  42. free(ptr);
  43. }
  44. // deallocation functions since c++14
  45. #if __cplusplus >= 201402L
  46. void operator delete(void* ptr, size_t sz)
  47. {
  48. free(ptr);
  49. }
  50. void operator delete[](void* ptr, size_t sz)
  51. {
  52. free(ptr);
  53. }
  54. #endif
  55. // placement deallocation functions
  56. void operator delete(void* /*ptr*/, void* /*voidptr2*/)
  57. {
  58. }
  59. void operator delete[](void* /*ptr*/, void* /*voidptr2*/)
  60. {
  61. }
  62. extern "C" void __cxa_pure_virtual()
  63. {
  64. NCNN_LOGE("[Fatal] Pure virtual func called, now exit.");
  65. // do not abort here to avoid more unpredictable behaviour
  66. }
  67. #endif // NCNN_SIMPLESTL