mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
8
applications/test/alloc/Make/files
Normal file
8
applications/test/alloc/Make/files
Normal file
@ -0,0 +1,8 @@
|
||||
allocTest.C
|
||||
/*
|
||||
newTest.C
|
||||
mallocTest.C
|
||||
test.C
|
||||
*/
|
||||
|
||||
SEXE = $(FOAM_USER_APPBIN)/allocTest
|
||||
2
applications/test/alloc/Make/options
Normal file
2
applications/test/alloc/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
|
||||
/* EXE_LIBS = -lfiniteVolume */
|
||||
27
applications/test/alloc/allocTest.C
Normal file
27
applications/test/alloc/allocTest.C
Normal file
@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int *ptrs[500000];
|
||||
|
||||
// for (;;);
|
||||
|
||||
cerr << "allocating ints\n";
|
||||
|
||||
for (int i=0; i<500000; i++)
|
||||
{
|
||||
ptrs[i] = new int[1];
|
||||
delete[] ptrs[i];
|
||||
}
|
||||
|
||||
for (;;);
|
||||
|
||||
cerr << "allocating double\n";
|
||||
|
||||
double* array = new double[500000];
|
||||
|
||||
for (;;);
|
||||
}
|
||||
30
applications/test/alloc/mallocTest.C
Normal file
30
applications/test/alloc/mallocTest.C
Normal file
@ -0,0 +1,30 @@
|
||||
#include "stream.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int *ptrs[500000];
|
||||
|
||||
cerr << "allocating ints\n";
|
||||
|
||||
for (int i=0; i<500000; i++)
|
||||
{
|
||||
ptrs[i] = (int*)malloc(sizeof(int));
|
||||
}
|
||||
|
||||
// for (;;);
|
||||
|
||||
cerr << "deallocating ints\n";
|
||||
|
||||
for (i=0; i<500000; i++)
|
||||
{
|
||||
free(ptrs[i]);
|
||||
}
|
||||
|
||||
cerr << "allocating double\n";
|
||||
|
||||
double* array = (double*)malloc(500000*sizeof(double));
|
||||
|
||||
for (;;);
|
||||
}
|
||||
30
applications/test/alloc/newTest.C
Normal file
30
applications/test/alloc/newTest.C
Normal file
@ -0,0 +1,30 @@
|
||||
#include <stream.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int* intPtrs[500000];
|
||||
|
||||
cerr << "allocating ints\n";
|
||||
|
||||
for (int i=0; i<500000; i++)
|
||||
{
|
||||
intPtrs[i] = new int[1];
|
||||
}
|
||||
|
||||
cerr << "allocated ints\n";
|
||||
|
||||
cerr << "deallocating ints\n";
|
||||
|
||||
for (i=0; i<500000; i++)
|
||||
{
|
||||
delete[] intPtrs[i];
|
||||
}
|
||||
|
||||
cerr << "deallocated ints\n";
|
||||
|
||||
cerr << "alloacting doubles\n";
|
||||
|
||||
double* doubles = new double[500000];
|
||||
|
||||
for (;;);
|
||||
}
|
||||
64
applications/test/alloc/test.C
Normal file
64
applications/test/alloc/test.C
Normal file
@ -0,0 +1,64 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
class Int
|
||||
{
|
||||
int I;
|
||||
|
||||
public:
|
||||
|
||||
Int(){}
|
||||
|
||||
operator int()
|
||||
{
|
||||
return I;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class List : public T
|
||||
{
|
||||
T* v;
|
||||
int sz;
|
||||
|
||||
public:
|
||||
|
||||
List()
|
||||
{
|
||||
v = new T[sz=10];
|
||||
}
|
||||
|
||||
List(int s)
|
||||
{
|
||||
v = new T[sz=s];
|
||||
}
|
||||
|
||||
~List()
|
||||
{
|
||||
delete[] v;
|
||||
}
|
||||
|
||||
inline int size() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
inline int List<T>::size() const
|
||||
{
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
#include <stream.h>
|
||||
|
||||
main()
|
||||
{
|
||||
typedef List<Int> intList;
|
||||
|
||||
intList list(10);
|
||||
|
||||
cout << list.size() << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user