Skip to content

Commit

Permalink
More Replace NULL with nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed Jun 3, 2024
1 parent bb72e14 commit 83f11bc
Show file tree
Hide file tree
Showing 47 changed files with 107 additions and 107 deletions.
2 changes: 1 addition & 1 deletion layer0/Field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PyObject *FieldAsNumPyArray(CField * field, short copy)
PyObject *result;
int typenum = -1;

import_array1(NULL);
import_array1(nullptr);

if(field->type == cFieldFloat) {
switch(field->base_size) {
Expand Down
2 changes: 1 addition & 1 deletion layer0/GenericBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct AttribOpFuncData {
AttribOpFuncData(AttribOpFuncDataFunctionPtr _funcDataConversion,
void *_funcDataGlobalArg,
const char *_attribName)
: funcDataConversion(_funcDataConversion), funcDataGlobalArg(_funcDataGlobalArg), attribName(_attribName), attrib(NULL){}
: funcDataConversion(_funcDataConversion), funcDataGlobalArg(_funcDataGlobalArg), attribName(_attribName), attrib(nullptr){}
};

using AttribOpFuncDataDesc = std::vector< AttribOpFuncData >;
Expand Down
2 changes: 1 addition & 1 deletion layer0/Isosurf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ PyObject *IsosurfAsPyList(PyMOLGlobals * G, Isofield * field)
if(field->save_points)
PyList_SetItem(result, 3, FieldAsPyList(G, field->points.get()));
else
PyList_SetItem(result, 3, PConvAutoNone(NULL));
PyList_SetItem(result, 3, PConvAutoNone(nullptr));
return (PConvAutoNone(result));
}

Expand Down
2 changes: 1 addition & 1 deletion layer0/MemoryCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ Z* -------------------------------------------------------------------
#define CacheAlloc(G,type,size,thread,id) pymol::malloc<type>(size)
#define CacheCalloc(G,type,size,thread,id) pymol::calloc<type>(size)
#define CacheRealloc(G,ptr,type,size,thread,id) pymol::realloc<type>(size)
#define CacheFreeP(G,ptr,thread,id,force) {if(ptr) {mfree(ptr);ptr=NULL;}}
#define CacheFreeP(G,ptr,thread,id,force) {if(ptr) {mfree(ptr);ptr=nullptr;}}

#endif
6 changes: 3 additions & 3 deletions layer0/MemoryDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ template <typename T> T* realloc(T* ptr, size_t num)
}
} // namespace pymol

#define FreeP(ptr) {if(ptr) {mfree(ptr);ptr=NULL;}}
#define DeleteP(ptr) {if(ptr) {delete ptr;ptr=NULL;}}
#define DeleteAP(ptr) {if(ptr) {delete[] ptr;ptr=NULL;}}
#define FreeP(ptr) {if(ptr) {mfree(ptr);ptr=nullptr;}}
#define DeleteP(ptr) {if(ptr) {delete ptr;ptr=nullptr;}}
#define DeleteAP(ptr) {if(ptr) {delete[] ptr;ptr=nullptr;}}

void *VLAExpand(void *ptr, ov_size rec); /* NOTE: rec is index (total-1) */
void *MemoryReallocForSure(void *ptr, size_t newSize);
Expand Down
20 changes: 10 additions & 10 deletions layer1/CGO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,7 @@ void SetVertexValuesForVBO(PyMOLGlobals * G, CGO *cgo, int pl, int plc, int cnt,
float *vertexVals, uchar *normalValsC,
float *normalVals, uchar *colorValsUC, float *colorVals,
float *pickColorVals,
float *accessibilityVals=NULL,
float *accessibilityVals=nullptr,
const float *accessibilityValsDA=nullptr)
{
int pl2 = pl + 1, pl3 = pl + 2;
Expand Down Expand Up @@ -2834,7 +2834,7 @@ CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders, float *
"%s-Error(%d): vertexVals could not be allocated (tot=%zu)\n", __func__,
__LINE__, tot ENDFB(G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
normalVals = vertexVals + 3 * num_total_indexes;
unsigned nxtn = VERTEX_NORMAL_SIZE;
Expand Down Expand Up @@ -2863,7 +2863,7 @@ CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders, float *
PRINTFB(G, FB_CGO, FB_Errors) "ERROR: CGOProcessCGOtoArrays() could not allocate enough memory\n" ENDFB(G);
FreeP(vertexVals);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
if (ok){
auto fmt = GetNormalColorFormatSize(G);
Expand Down Expand Up @@ -2913,7 +2913,7 @@ CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders, float *
PRINTFB(G, FB_CGO, FB_Errors) "CGOOptimizeToVBONotIndexedWithReturnedData: ERROR: CGODrawBuffersNotIndexed() could not allocate enough memory\n" ENDFB(G);
FreeP(vertexVals);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
memcpy(newPickColorVals + num_total_indexes, pickColorVals, num_total_indexes * 2 * sizeof(float));
has_draw_buffer = true;
Expand Down Expand Up @@ -2950,7 +2950,7 @@ CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders, float *
"%s-Error(%d): vertexVals could not be allocated (tot=%zu)\n", __func__,
__LINE__, tot ENDFB(G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
normalVals = vertexVals + 3 * num_total_indexes_lines;
nxtn = 3;
Expand Down Expand Up @@ -3152,7 +3152,7 @@ CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders, float *
G->ShaderMgr->freeGPUBuffer(pickvboid);
G->ShaderMgr->freeGPUBuffer(vboid);
}
return (NULL);
return (nullptr);
}
memcpy(newPickColorVals + num_total_indexes_lines, pickColorVals, num_total_indexes_lines * 2 * sizeof(float));
has_draw_buffer = true;
Expand Down Expand Up @@ -3273,7 +3273,7 @@ CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est,
if (vertexIndices.empty()) {
PRINTFB(I->G, FB_CGO, FB_Errors) "ERROR: CGOOptimizeToVBOIndexed() vertexIndices could not be allocated\n" ENDFB(I->G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}

unsigned mul = VERTEX_POS_SIZE + VERTEX_PICKCOLOR_SIZE + VERTEX_ACCESSIBILITY_SIZE;
Expand All @@ -3287,7 +3287,7 @@ CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est,
"%s-Error(%d): vertexVals could not be allocated (tot=%zu)\n", __func__,
__LINE__, tot ENDFB(G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
normalVals = vertexVals + 3 * num_total_vertices;
nxtn = 3;
Expand Down Expand Up @@ -3572,7 +3572,7 @@ CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est,
if (vertexIndexes.empty()) {
PRINTFB(I->G, FB_CGO, FB_Errors) "ERROR: CGOOptimizeToVBOIndexed() vertexIndexes could not be allocated\n" ENDFB(I->G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}

unsigned mul = VERTEX_POS_SIZE + VERTEX_PICKCOLOR_SIZE;
Expand All @@ -3588,7 +3588,7 @@ CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est,
"%s-Error(%d): vertexVals could not be allocated (tot=%zu)\n", __func__,
__LINE__, tot ENDFB(G);
CGOFree(cgo);
return (NULL);
return (nullptr);
}
nxtVals = vertexVals + VERTEX_POS_SIZE * num_total_vertices_lines;

Expand Down
8 changes: 4 additions & 4 deletions layer1/CGO.h
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ CGO* CGOCombineBeginEnd(const CGO* I, int est = 0, bool do_not_split_lines = fal

void CGOFreeVBOs(CGO *I);

CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est=0, const float *color=NULL, bool addshaders=true, bool embedTransparencyInfo=false);
CGO *CGOOptimizeToVBOIndexed(const CGO * I, int est=0, const float *color=nullptr, bool addshaders=true, bool embedTransparencyInfo=false);
#define CGOOptimizeToVBOIndexedWithColorEmbedTransparentInfo(I, est, color, addshaders) CGOOptimizeToVBOIndexed(I, est, color, addshaders, true)
#define CGOOptimizeToVBOIndexedWithColor CGOOptimizeToVBOIndexed
#define CGOOptimizeToVBOIndexedNoShader(I, est) CGOOptimizeToVBOIndexed(I, est, nullptr, false)
Expand All @@ -969,7 +969,7 @@ CGO* CGOOptimizeToVBONotIndexed(const CGO* I, int est = 0,
#define CGOOptimizeToVBONotIndexedNoShader(I) CGOOptimizeToVBONotIndexed(I, 0, false)


CGO *CGOOptimizeSpheresToVBONonIndexed(const CGO * I, int est=0, bool addshaders=false, CGO *leftOverCGO=NULL);
CGO *CGOOptimizeSpheresToVBONonIndexed(const CGO * I, int est=0, bool addshaders=false, CGO *leftOverCGO=nullptr);
#define CGOOptimizeSpheresToVBONonIndexedNoShader(I, est) CGOOptimizeSpheresToVBONonIndexed(I, est, false, nullptr)

/**
Expand Down Expand Up @@ -1082,7 +1082,7 @@ int CGOAlphaTriangle(CGO * I,
void CGOSetZVector(CGO * I, float z0, float z1, float z2);
struct GadgetSet;
void CGORenderPicking(CGO * I, RenderInfo *info,
PickContext * context, CSetting * set1, CSetting * set2, Rep *rep=NULL);
PickContext * context, CSetting * set1, CSetting * set2, Rep *rep=nullptr);
void CGORender(CGO * I, const float *color, CSetting * set1, CSetting * set2,
RenderInfo * info, Rep *rep);
void CGORenderAlpha(CGO * I, RenderInfo * info, bool calcDepth);
Expand Down Expand Up @@ -1184,7 +1184,7 @@ int CGOUniform3f(CGO *I, int uniform_id, const float *value);

CGO *CGOConvertSpheresToPoints(const CGO *I);

CGO *CGOConvertToShader(const CGO *I, AttribDataDesc &attrData, AttribDataDesc &pickData, int mode, const VertexBuffer::buffer_layout layout=VertexBuffer::INTERLEAVED, bool check_attr_for_data=true, int *idx_array=NULL, int nindicesperfrag=0, int nfragspergroup = 1);
CGO *CGOConvertToShader(const CGO *I, AttribDataDesc &attrData, AttribDataDesc &pickData, int mode, const VertexBuffer::buffer_layout layout=VertexBuffer::INTERLEAVED, bool check_attr_for_data=true, int *idx_array=nullptr, int nindicesperfrag=0, int nfragspergroup = 1);

bool CGOCheckSplitLineInterpolationIsSame(const CGO *I, bool &interp_value);

Expand Down
2 changes: 1 addition & 1 deletion layer1/Color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ const char *ColorGetName(PyMOLGlobals * G, int index)
} else
return nullptr;
}
return (NULL);
return (nullptr);
}


Expand Down
6 changes: 3 additions & 3 deletions layer1/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,17 @@ PyObject *MovieAsPyList(PyMOLGlobals * G)
if(I->Sequence) {
PyList_SetItem(result, 4, PConvIntArrayToPyList(I->Sequence, I->NFrame));
} else {
PyList_SetItem(result, 4, PConvAutoNone(NULL));
PyList_SetItem(result, 4, PConvAutoNone(nullptr));
}
if(!I->Cmd.empty()) {
PyList_SetItem(result, 5, MovieCmdAsPyList(G));
} else {
PyList_SetItem(result, 5, PConvAutoNone(NULL));
PyList_SetItem(result, 5, PConvAutoNone(nullptr));
}
if(I->ViewElem) {
PyList_SetItem(result, 6, ViewElemVLAAsPyList(G, I->ViewElem, I->NFrame));
} else {
PyList_SetItem(result, 6, PConvAutoNone(NULL));
PyList_SetItem(result, 6, PConvAutoNone(nullptr));
}


Expand Down
2 changes: 1 addition & 1 deletion layer1/P.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ static ov_status CacheCreateEntry(PyObject ** result, PyObject * input)
PyList_SetItem(entry, 0, PyInt_FromLong(tot_size));
PyList_SetItem(entry, 1, hash_code);
PyList_SetItem(entry, 2, PXIncRef(input));
PyList_SetItem(entry, 3, PXIncRef(NULL));
PyList_SetItem(entry, 3, PXIncRef(nullptr));
PyList_SetItem(entry, 4, PyInt_FromLong(0)); /* access count */
PyList_SetItem(entry, 5, PyFloat_FromDouble(0.0)); /* timestamp */
}
Expand Down
2 changes: 1 addition & 1 deletion layer1/PyMOLObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ PyObject *ObjectAsPyList(const pymol::CObject * I)
PyList_SetItem(result, 13, ViewElemVLAAsPyList(I->G, I->ViewElem, nFrame));
} else {
PyList_SetItem(result, 12, PyInt_FromLong(0));
PyList_SetItem(result, 13, PConvAutoNone(NULL));
PyList_SetItem(result, 13, PConvAutoNone(nullptr));
}
return (PConvAutoNone(result));
}
Expand Down
2 changes: 1 addition & 1 deletion layer1/Ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ static void RayHashSpawn(CRayHashThreadInfo * Thread, int n_thread, int n_total)
PyList_SetItem(
info_list, a, PyCapsule_New(Thread + c + a, nullptr, nullptr));
} else {
PyList_SetItem(info_list, a, PConvAutoNone(NULL));
PyList_SetItem(info_list, a, PConvAutoNone(nullptr));
}
n++;
}
Expand Down
2 changes: 1 addition & 1 deletion layer1/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4925,7 +4925,7 @@ const char * lightsource_diffuse_names[] = {
#undef TEMPLATE

/**
* Sets up lighting for immediate mode if shaderPrg=NULL, otherwise
* Sets up lighting for immediate mode if shaderPrg=nullptr, otherwise
* sets lighting uniforms for the given shader program.
*
* Supports up to light_count=8
Expand Down
2 changes: 1 addition & 1 deletion layer1/SceneRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ void SceneInitializeViewport(PyMOLGlobals* G, bool offscreen)
G, I, I->vp_stereo_mode, 0, I->vp_times, I->vp_pos, I->vp_oversize);
} else {
PRINTFB(G, FB_Scene, FB_Errors)
" SceneInitializeViewport: I->vp_prepareViewPortForStereo=NULL\n" ENDFB(
" SceneInitializeViewport: I->vp_prepareViewPortForStereo=nullptr\n" ENDFB(
G);
}
}
Expand Down
2 changes: 1 addition & 1 deletion layer1/Setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const char * SettingGetTextPtr(PyMOLGlobals * G, const CSetting * set1, const CS

int SettingUnset(CSetting * I, int index);

void SettingRestoreDefault(CSetting * I, int index, const CSetting * src=NULL);
void SettingRestoreDefault(CSetting * I, int index, const CSetting * src=nullptr);

int SettingGetType(int index);
inline int SettingGetType(PyMOLGlobals *, int index) {
Expand Down
18 changes: 9 additions & 9 deletions layer1/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,37 +351,37 @@ PyObject *ViewElemAsPyList(PyMOLGlobals * G, const CViewElem * view)
if(view->matrix_flag) {
PyList_SetItem(result, 1, PConvDoubleArrayToPyList(view->matrix, 16));
} else {
PyList_SetItem(result, 1, PConvAutoNone(NULL));
PyList_SetItem(result, 1, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 2, PyInt_FromLong(view->pre_flag));
if(view->pre_flag) {
PyList_SetItem(result, 3, PConvDoubleArrayToPyList(view->pre, 3));
} else {
PyList_SetItem(result, 3, PConvAutoNone(NULL));
PyList_SetItem(result, 3, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 4, PyInt_FromLong(view->post_flag));
if(view->post_flag) {
PyList_SetItem(result, 5, PConvDoubleArrayToPyList(view->post, 3));
} else {
PyList_SetItem(result, 5, PConvAutoNone(NULL));
PyList_SetItem(result, 5, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 6, PyInt_FromLong(view->clip_flag));
if(view->post_flag) {
PyList_SetItem(result, 7, PyFloat_FromDouble((double) view->front));
PyList_SetItem(result, 8, PyFloat_FromDouble((double) view->back));
} else {
PyList_SetItem(result, 7, PConvAutoNone(NULL));
PyList_SetItem(result, 8, PConvAutoNone(NULL));
PyList_SetItem(result, 7, PConvAutoNone(nullptr));
PyList_SetItem(result, 8, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 9, PyInt_FromLong(view->ortho_flag));
if(view->ortho_flag) {
PyList_SetItem(result, 10, PyFloat_FromDouble(view->ortho));
} else {
PyList_SetItem(result, 10, PConvAutoNone(NULL));
PyList_SetItem(result, 10, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 11, PyInt_FromLong(view->view_mode));
Expand All @@ -404,21 +404,21 @@ PyObject *ViewElemAsPyList(PyMOLGlobals * G, const CViewElem * view)
if(view->ortho_flag) {
PyList_SetItem(result, 16, PyFloat_FromDouble(view->power));
} else {
PyList_SetItem(result, 16, PConvAutoNone(NULL));
PyList_SetItem(result, 16, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 17, PyInt_FromLong(view->bias_flag));
if(view->bias_flag) {
PyList_SetItem(result, 18, PyFloat_FromDouble(view->bias));
} else {
PyList_SetItem(result, 18, PConvAutoNone(NULL));
PyList_SetItem(result, 18, PConvAutoNone(nullptr));
}

PyList_SetItem(result, 19, PyInt_FromLong(view->state_flag));
if(view->state_flag) {
PyList_SetItem(result, 20, PyInt_FromLong(view->state));
} else {
PyList_SetItem(result, 20, PConvAutoNone(NULL));
PyList_SetItem(result, 20, PConvAutoNone(nullptr));
}

}
Expand Down
10 changes: 5 additions & 5 deletions layer2/CoordSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ PyObject *CoordSetAsNumPyArray(CoordSet * cs, short copy)
int typenum = -1;
npy_intp dims[2] = {0, 3};

import_array1(NULL);
import_array1(nullptr);

switch(base_size) {
case 4: typenum = NPY_FLOAT32; break;
Expand Down Expand Up @@ -378,7 +378,7 @@ PyObject *CoordSetAsPyList(CoordSet * I)
&& pse_export_version < 1770)
PyList_SetItem(result, 4, PConvIntArrayToPyList(I->AtmToIdx.data(), NAtIndex, dump_binary));
else
PyList_SetItem(result, 4, PConvAutoNone(NULL));
PyList_SetItem(result, 4, PConvAutoNone(nullptr));
PyList_SetItem(result, 5, PyString_FromString(I->Name));
PyList_SetItem(result, 6, ObjectStateAsPyList(I));
PyList_SetItem(result, 7, SettingAsPyList(I->Setting.get()));
Expand All @@ -392,7 +392,7 @@ PyObject *CoordSetAsPyList(CoordSet * I)
if(I->SculptCGO) {
PyList_SetItem(result, 10, CGOAsPyList(I->SculptCGO));
} else {
PyList_SetItem(result, 10, PConvAutoNone(NULL));
PyList_SetItem(result, 10, PConvAutoNone(nullptr));
}
if (I->has_any_atom_state_settings()) {
int a;
Expand All @@ -402,12 +402,12 @@ PyObject *CoordSetAsPyList(CoordSet * I)
if (I->has_atom_state_settings(a)) {
PyList_SetItem(settings_list, a, PyInt_FromLong(I->atom_state_setting_id[a]));
} else {
PyList_SetItem(settings_list, a, PConvAutoNone(NULL));
PyList_SetItem(settings_list, a, PConvAutoNone(nullptr));
}
}
PyList_SetItem(result, 11, settings_list);
} else {
PyList_SetItem(result, 11, PConvAutoNone(NULL));
PyList_SetItem(result, 11, PConvAutoNone(nullptr));
}
PyList_SetItem(result, 12, SymmetryAsPyList(I->Symmetry.get()));
/* TODO spheroid, periodic box ... */
Expand Down
2 changes: 1 addition & 1 deletion layer2/CoordSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void CoordSetFracToReal(CoordSet * I, const CCrystal * cryst);
bool CoordSetInsureOrthogonal(PyMOLGlobals * G,
CoordSet * cset,
const float * sca,
const CCrystal *cryst=NULL,
const CCrystal *cryst=nullptr,
bool quiet=true);

void CoordSetGetAverage(const CoordSet * I, float *v0);
Expand Down
Loading

0 comments on commit 83f11bc

Please sign in to comment.