Commit 246d569c authored by Mark Olesen's avatar Mark Olesen
Browse files

consistency update for null pointers

- uniform use of reinterpret_cast<foo*>(0) instead of
  reinterpret_cast<foo*>(NULL)

- make all static null() members inline since they are really only a cast:
      "*reinterpret_cast<foo*>(0)"
parent a2b24d07
......@@ -51,7 +51,7 @@ cellShape create3DCellShape
static List<const cellModel*> fluentCellModelLookup
(
7,
reinterpret_cast<const cellModel*>(NULL)
reinterpret_cast<const cellModel*>(0)
);
fluentCellModelLookup[2] = cellModeller::lookup("tet");
......
......@@ -90,13 +90,13 @@ const label sammMesh::shapeFaceLookup[19][9] =
List<const cellModel*> sammMesh::sammShapeLookup
(
256,
reinterpret_cast<cellModel*>(NULL)
reinterpret_cast<cellModel*>(0)
);
List<const label*> sammMesh::sammAddressingTable
(
256,
reinterpret_cast<label*>(NULL)
reinterpret_cast<label*>(0)
);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -48,7 +48,7 @@ void starMesh::addRegularCell
label regularTypeFlag = -1;
// grab the shape from the table
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
if // Tetrahedron
(
......@@ -130,7 +130,7 @@ void starMesh::addSAMMcell
// grab the shape from the table
label sammTypeFlag = -1;
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(NULL);
const cellModel* curModelPtr = reinterpret_cast<cellModel*>(0);
switch (typeFlag)
{
......
......@@ -299,7 +299,7 @@ bool domainDecomposition::writeDecomposition()
(
curPatchSizes.size()
+ curProcessorPatchSizes.size(),
reinterpret_cast<polyPatch*>(NULL)
reinterpret_cast<polyPatch*>(0)
);
label nPatches = 0;
......
......@@ -3,7 +3,7 @@ int nFields = volScalarNames.size() + 3*volVectorNames.size();
List<volScalarField*> volFieldPtrs
(
nFields,
reinterpret_cast<volScalarField*>(NULL)
reinterpret_cast<volScalarField*>(0)
);
stringList volFieldNames(nFields);
......@@ -27,12 +27,11 @@ nFields = 0;
if (ioHeader.headerOk())
{
volFieldPtrs[nFields] =
new volScalarField
(
ioHeader,
mesh
);
volFieldPtrs[nFields] = new volScalarField
(
ioHeader,
mesh
);
}
fieldName = getFieldViewName(fieldName);
......@@ -106,7 +105,7 @@ int nSurfFields = surfScalarNames.size() + 3*surfVectorNames.size();
List<surfaceScalarField*> surfFieldPtrs
(
nSurfFields,
reinterpret_cast<surfaceScalarField*>(NULL)
reinterpret_cast<surfaceScalarField*>(0)
);
stringList surfFieldNames(nSurfFields);
......
......@@ -2,13 +2,13 @@
List<IOField<scalar>* > sprayScalarFieldPtrs
(
sprayScalarNames.size(),
reinterpret_cast<IOField<scalar>*>(NULL)
reinterpret_cast<IOField<scalar>*>(0)
);
List<IOField<vector>* > sprayVectorFieldPtrs
(
sprayVectorNames.size(),
reinterpret_cast<IOField<vector>*>(NULL)
reinterpret_cast<IOField<vector>*>(0)
);
{
......
......@@ -24,7 +24,7 @@ License
Description
Translates a STAR-CD SMAP data file into FOAM field format.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
......@@ -108,15 +108,15 @@ int main(int argc, char *argv[])
List<volScalarField*> sFields
(
nCols,
reinterpret_cast<volScalarField*>(NULL)
reinterpret_cast<volScalarField*>(0)
);
List<volVectorField*> vFields
(
nCols,
reinterpret_cast<volVectorField*>(NULL)
reinterpret_cast<volVectorField*>(0)
);
label i=0;
while (i < nCols)
{
......
......@@ -92,14 +92,6 @@ public:
HashTable<T, label, Hash<label> >(map)
{}
//- Return a null Map
static const Map<T>& null()
{
Map<T>* nullPtr = reinterpret_cast<Map<T>*>(0);
return *nullPtr;
}
};
......
......@@ -40,7 +40,7 @@ Foam::DLListBase::iterator Foam::DLListBase::endIter
Foam::DLListBase::const_iterator Foam::DLListBase::endConstIter
(
static_cast<const DLListBase&>(DLListBase()),
reinterpret_cast<const link*>(NULL)
reinterpret_cast<const link*>(0)
);
......
......@@ -37,7 +37,7 @@ Foam::SLListBase::iterator Foam::SLListBase::endIter
Foam::SLListBase::const_iterator Foam::SLListBase::endConstIter
(
static_cast<const SLListBase&>(SLListBase()),
reinterpret_cast<const link*>(NULL)
reinterpret_cast<const link*>(0)
);
......
......@@ -118,14 +118,6 @@ Foam::CompactListList<T>::CompactListList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
{
CompactListList<T>* nullPtr = reinterpret_cast<CompactListList<T>*>(NULL);
return *nullPtr;
}
template<class T>
void Foam::CompactListList<T>::setSize(const label nRows)
{
......
......@@ -81,6 +81,11 @@ class CompactListList
public:
// Static Member Functions
//- Return a null CompactListList
inline static const CompactListList<T>& null();
// Constructors
//- Null constructor.
......@@ -116,10 +121,7 @@ public:
inline autoPtr<CompactListList<T> > clone() const;
// Member functions
//- Return a null CompactListList
static const CompactListList<T>& null();
// Member Functions
// Access
......
......@@ -67,6 +67,13 @@ Foam::CompactListList<T>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
{
return *reinterpret_cast< CompactListList<T>* >(0);
}
template<class T>
inline Foam::label Foam::CompactListList<T>::size() const
{
......
......@@ -29,14 +29,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label Size>
const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
{
FixedList<T, Size>* nullPtr = reinterpret_cast<FixedList<T, Size>*>(NULL);
return *nullPtr;
}
// * * * * * * * * * * * * * * STL Member Functions * * * * * * * * * * * * //
template<class T, Foam::label Size>
......
......@@ -93,6 +93,11 @@ public:
) const;
};
// Static Member Functions
//- Return a null FixedList
inline static const FixedList<T, Size>& null();
// Constructors
......@@ -121,11 +126,7 @@ public:
inline autoPtr<FixedList<T, Size> > clone() const;
// Member functions
//- Return a null FixedList
static const FixedList<T, Size>& null();
// Member Functions
// Access
......
......@@ -104,6 +104,13 @@ Foam::FixedList<T, Size>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label Size>
inline const Foam::FixedList<T, Size>& Foam::FixedList<T, Size>::null()
{
return *reinterpret_cast< FixedList<T, Size>* >(0);
}
template<class T, Foam::label Size>
inline Foam::label Foam::FixedList<T, Size>::fcIndex(const label i) const
{
......
......@@ -332,14 +332,6 @@ Foam::List<T>::~List()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
const Foam::List<T>& Foam::List<T>::null()
{
List<T>* nullPtr = reinterpret_cast<List<T>*>(NULL);
return *nullPtr;
}
template<class T>
void Foam::List<T>::setSize(const label newSize)
{
......
......@@ -87,6 +87,11 @@ protected:
public:
// Static Member Functions
//- Return a null List
inline static const List<T>& null();
// Constructors
//- Null constructor.
......@@ -145,10 +150,7 @@ public:
typedef SubList<T> subList;
// Member functions
//- Return a null List
static const List<T>& null();
// Member Functions
//- Return the number of elements in the UList.
inline label size() const;
......
......@@ -40,6 +40,13 @@ inline Foam::autoPtr<Foam::List<T> > Foam::List<T>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const Foam::List<T>& Foam::List<T>::null()
{
return *reinterpret_cast< List<T>* >(0);
}
template<class T>
inline T& Foam::List<T>::newElmt(const label i)
{
......
......@@ -42,7 +42,7 @@ Foam::PtrList<T>::PtrList()
template<class T>
Foam::PtrList<T>::PtrList(const label s)
:
ptrs_(s, reinterpret_cast<T*>(NULL))
ptrs_(s, reinterpret_cast<T*>(0))
{}
......@@ -216,7 +216,7 @@ void Foam::PtrList<T>::reorder(const UList<label>& oldToNew)
<< ")." << abort(FatalError);
}
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(NULL));
List<T*> newPtrs_(ptrs_.size(), reinterpret_cast<T*>(0));
forAll(*this, i)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment