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)
{
......
......@@ -59,6 +59,12 @@ class SubList
public:
// Static Member Functions
//- Return a null SubList
inline static const SubList<T>& null();
// Constructors
//- Construct from UList and sub-list size
......@@ -77,12 +83,6 @@ public:
);
// Member functions
//- Return a null SubList
static inline const SubList<T>& null();
// Member operators
//- Allow cast to a const List<T>&
......
......@@ -75,8 +75,7 @@ inline Foam::SubList<T>::SubList
template<class T>
inline const Foam::SubList<T>& Foam::SubList<T>::null()
{
SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL);
return *nullPtr;
return *reinterpret_cast< SubList<T>* >(0);
}
......
......@@ -32,14 +32,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
const Foam::UList<T>& Foam::UList<T>::null()
{
UList<T>* nullPtr = reinterpret_cast<UList<T>*>(NULL);
return *nullPtr;
}
template<class T>
void Foam::UList<T>::assign(const UList<T>& a)
{
......
......@@ -86,6 +86,11 @@ public:
//- Declare friendship with the SubList class
friend class SubList<T>;
// Static Member Functions
//- Return a null UList
inline static const UList<T>& null();
// Public classes
//- Less function class that can be used for sorting
......@@ -116,10 +121,7 @@ public:
inline UList(T* __restrict__ v, label size);
// Member functions
//- Return a null UList
static const UList<T>& null();
// Member Functions
// Access
......
......@@ -47,6 +47,13 @@ inline Foam::UList<T>::UList(T* __restrict__ v, label size)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const Foam::UList<T>& Foam::UList<T>::null()
{
return *reinterpret_cast< UList<T>* >(0);
}
template<class T>
inline Foam::label Foam::UList<T>::fcIndex(const label i) const
{
......
......@@ -41,7 +41,7 @@ Foam::UPtrList<T>::UPtrList()
template<class T>
Foam::UPtrList<T>::UPtrList(const label s)
:
ptrs_(s, reinterpret_cast<T*>(NULL))
ptrs_(s, reinterpret_cast<T*>(0))
{}
......@@ -114,7 +114,7 @@ void Foam::UPtrList<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)
{
......
......@@ -271,16 +271,6 @@ DimensionedField<Type, GeoMesh>::~DimensionedField()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Return a null Field
template<class Type, class GeoMesh>
const DimensionedField<Type, GeoMesh>& DimensionedField<Type, GeoMesh>::null()
{
DimensionedField<Type, GeoMesh>* nullPtr =
reinterpret_cast<DimensionedField<Type, GeoMesh>*>(NULL);
return *nullPtr;
}
template<class Type, class GeoMesh>
tmp
<
......
......@@ -100,6 +100,11 @@ public:
//- Runtime type information
TypeName("DimensionedField");
// Static Member Functions
//- Return a null DimensionedField
inline static const DimensionedField<Type, GeoMesh>& null();
// Constructors
......@@ -232,9 +237,6 @@ public:
inline Field<Type>& field();
//- Return a null DimensionedField
static const DimensionedField<Type, GeoMesh>& null();
//- Return a component field of the field
tmp<DimensionedField<cmptType, GeoMesh> > component
(
......
......@@ -31,6 +31,14 @@ namespace Foam
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
inline const DimensionedField<Type, GeoMesh>&
DimensionedField<Type, GeoMesh>::null()
{
return *reinterpret_cast< DimensionedField<Type, GeoMesh>* >(0);
}
template<class Type, class GeoMesh>
inline const typename GeoMesh::Mesh&
DimensionedField<Type, GeoMesh>::mesh() const
......
......@@ -81,9 +81,7 @@ template<class Type, class GeoMesh>
inline const SubDimensionedField<Type, GeoMesh>&
SubDimensionedField<Type, GeoMesh>::null()
{
SubDimensionedField<Type, GeoMesh>* nullPtr
= reinterpret_cast<SubDimensionedField<Type, GeoMesh>*>(NULL);
return *nullPtr;
return *reinterpret_cast< SubDimensionedField<Type, GeoMesh>* >(0);
}
......
......@@ -298,14 +298,6 @@ tmp<Field<Type> > Field<Type>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
const Field<Type>& Field<Type>::null()
{
Field<Type>* nullPtr = reinterpret_cast<Field<Type>*>(NULL);
return *nullPtr;
}
template<class Type>
void Field<Type>::map
(
......
......@@ -98,6 +98,15 @@ public:
static const char* const typeName;
// Static Member Functions
//- Return a null field
inline static const Field<Type>& null()
{
return *reinterpret_cast< Field<Type>* >(0);
}
// Constructors
//- Construct null
......@@ -198,11 +207,7 @@ public:
#endif
// Member functions
//- Return a null Field
static const Field<Type>& null();
// Member Functions
//- 1 to 1 map from the given field
void map
......
......@@ -74,8 +74,7 @@ inline Foam::SubField<Type>::SubField
template<class Type>
inline const Foam::SubField<Type>& Foam::SubField<Type>::null()