createconf_new.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * DUMA - Red-Zone memory allocator.
  3. *
  4. * Copyright (C) 2008 Hayati Ayguen <h_ayguen@web.de>, Procitec GmbH
  5. *
  6. * License: GNU GPL (GNU General Public License, see COPYING-GPL)
  7. *
  8. * This program 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 program 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, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <stdlib.h>
  24. #include <new>
  25. #ifdef __cplusplus
  26. #define DUMA_EXTERN_C extern "C"
  27. #else
  28. #define DUMA_EXTERN_C extern
  29. #endif
  30. DUMA_EXTERN_C
  31. int get_new0strategy(void)
  32. {
  33. /* test for behaviour of operator new with size 0 */
  34. int op_new_0_strategy;
  35. int * piNullPtrA;
  36. int * piNullPtrB;
  37. piNullPtrA = (int*) operator new(0);
  38. piNullPtrB = (int*) operator new(0);
  39. if ( !piNullPtrA )
  40. op_new_0_strategy = 0;
  41. else if ( piNullPtrA == piNullPtrB )
  42. op_new_0_strategy = 1;
  43. else
  44. op_new_0_strategy = 2;
  45. return op_new_0_strategy;
  46. }