URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 38 |
Rev 156 |
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <new>
|
#include <new>
|
|
|
int pass = 0;
|
int pass = 0;
|
|
|
void *
|
void *
|
operator new (size_t sz, const std::nothrow_t&) throw ()
|
operator new (size_t sz, const std::nothrow_t&) throw ()
|
{
|
{
|
void *p;
|
void *p;
|
pass++;
|
pass++;
|
p = malloc(sz);
|
p = malloc(sz);
|
return p;
|
return p;
|
}
|
}
|
|
|
void *
|
void *
|
operator new (size_t sz) throw (std::bad_alloc)
|
operator new (size_t sz) throw (std::bad_alloc)
|
{
|
{
|
void *p;
|
void *p;
|
pass++;
|
pass++;
|
p = malloc(sz);
|
p = malloc(sz);
|
return p;
|
return p;
|
}
|
}
|
|
|
void
|
void
|
operator delete (void *ptr) throw ()
|
operator delete (void *ptr) throw ()
|
{
|
{
|
pass++;
|
pass++;
|
if (ptr)
|
if (ptr)
|
free (ptr);
|
free (ptr);
|
}
|
}
|
|
|
class A
|
class A
|
{
|
{
|
public:
|
public:
|
A() {}
|
A() {}
|
~A() { }
|
~A() { }
|
int a;
|
int a;
|
int b;
|
int b;
|
};
|
};
|
|
|
|
|
int
|
int
|
main (void)
|
main (void)
|
{
|
{
|
A *bb = new A[10];
|
A *bb = new A[10];
|
delete [] bb;
|
delete [] bb;
|
bb = new (std::nothrow) A [10];
|
bb = new (std::nothrow) A [10];
|
delete [] bb;
|
delete [] bb;
|
|
|
if (pass == 4)
|
if (pass == 4)
|
{
|
{
|
printf ("PASS\n");
|
printf ("PASS\n");
|
return 0;
|
return 0;
|
}
|
}
|
else
|
else
|
{
|
{
|
printf ("FAIL\n");
|
printf ("FAIL\n");
|
return 1;
|
return 1;
|
}
|
}
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.