cxx-support.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * dselect - Debian package maintenance user interface
  3. * cxx-support.cc - C++ support code for dselect
  4. *
  5. * Copyright © 1994-1996 Ian Jackson <ijackson@chiark.greenend.org.uk>
  6. * Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
  7. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. #include <config.h>
  22. #include <compat.h>
  23. #include <sys/types.h>
  24. #include <assert.h>
  25. #include <stdlib.h>
  26. #ifdef HAVE_CXXABI_H
  27. #include <cxxabi.h>
  28. #endif
  29. #include <new>
  30. #include <dpkg/dpkg.h>
  31. extern void *
  32. operator new(size_t size) DPKG_ATTR_THROW(std::bad_alloc)
  33. {
  34. void *p;
  35. p = m_malloc(size);
  36. assert(p);
  37. return p;
  38. }
  39. extern void *
  40. operator new[](size_t size) DPKG_ATTR_THROW(std::bad_alloc)
  41. {
  42. void *p;
  43. p = m_malloc(size);
  44. assert(p);
  45. return p;
  46. }
  47. extern void
  48. operator delete(void *p) DPKG_ATTR_NOEXCEPT
  49. {
  50. free(p);
  51. }
  52. extern void
  53. operator delete(void *p, size_t size) DPKG_ATTR_NOEXCEPT
  54. {
  55. free(p);
  56. }
  57. extern void
  58. operator delete[](void *a) DPKG_ATTR_NOEXCEPT
  59. {
  60. free(a);
  61. }
  62. extern void
  63. operator delete[](void *a, size_t size) DPKG_ATTR_NOEXCEPT
  64. {
  65. free(a);
  66. }
  67. #ifdef HAVE___CXA_PURE_VIRTUAL
  68. namespace __cxxabiv1 {
  69. extern "C" void
  70. __cxa_pure_virtual()
  71. {
  72. internerr("pure virtual function called");
  73. }
  74. }
  75. #endif