From 311031ecd03dbfbf43e1df672a395f24b2e7d4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Barschkis?= Date: Fri, 6 Nov 2020 11:44:05 +0100 Subject: Cleanup: Use nullptr everywhere in fluid code Switched from NULL to nullptr. --- extern/mantaflow/preprocessed/fileio/iogrids.cpp | 24 ++++++++++++------------ extern/mantaflow/preprocessed/fileio/ioutil.cpp | 2 +- extern/mantaflow/preprocessed/fileio/mantaio.cpp | 4 ++-- extern/mantaflow/preprocessed/fileio/mantaio.h | 12 ++++++++---- 4 files changed, 23 insertions(+), 19 deletions(-) (limited to 'extern/mantaflow/preprocessed/fileio') diff --git a/extern/mantaflow/preprocessed/fileio/iogrids.cpp b/extern/mantaflow/preprocessed/fileio/iogrids.cpp index 825ce0ae8b5..7cedbb484ba 100644 --- a/extern/mantaflow/preprocessed/fileio/iogrids.cpp +++ b/extern/mantaflow/preprocessed/fileio/iogrids.cpp @@ -440,7 +440,7 @@ static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "getUniFileSize", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; const string &name = _args.get("name", 0, &_lock); @@ -479,7 +479,7 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "printUniFileInfoString", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; const string &name = _args.get("name", 0, &_lock); @@ -715,7 +715,7 @@ template<> int writeGridVol(const string &name, Grid *grid) header.bboxMax = Vec3(0.5); FILE *fp = fopen(name.c_str(), "wb"); - if (fp == NULL) { + if (fp == nullptr) { errMsg("writeGridVol: Cannot open '" << name << "'"); return 0; } @@ -749,7 +749,7 @@ template<> int readGridVol(const string &name, Grid *grid) volHeader header; FILE *fp = fopen(name.c_str(), "rb"); - if (fp == NULL) { + if (fp == nullptr) { errMsg("readGridVol: Cannot open '" << name << "'"); return 0; } @@ -844,11 +844,11 @@ int readGrid4dUni( 1); #if NO_ZLIB != 1 - gzFile gzf = NULL; + gzFile gzf = nullptr; char ID[5] = {0, 0, 0, 0, 0}; // optionally - reuse file handle, if valid one is passed in fileHandle pointer... - if ((!fileHandle) || (fileHandle && (*fileHandle == NULL))) { + if ((!fileHandle) || (fileHandle && (*fileHandle == nullptr))) { gzf = (gzFile)safeGzopen(name.c_str(), "rb"); if (!gzf) { errMsg("readGrid4dUni: can't open file " << name); @@ -969,11 +969,11 @@ int readGrid4dUni( void readGrid4dUniCleanup(void **fileHandle) { #if NO_ZLIB != 1 - gzFile gzf = NULL; + gzFile gzf = nullptr; if (fileHandle) { gzf = (gzFile)(*fileHandle); gzclose(gzf); - *fileHandle = NULL; + *fileHandle = nullptr; } #else debMsg("file format not supported without zlib", 1); @@ -1171,7 +1171,7 @@ int readGridsNumpy(const string &name, std::vector *grids) // adopted from getUniFileSize void getNpzFileSize( - const string &name, int &x, int &y, int &z, int *t = NULL, std::string *info = NULL) + const string &name, int &x, int &y, int &z, int *t = nullptr, std::string *info = nullptr) { x = y = z = 0; @@ -1207,7 +1207,7 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "getNpzFileSize", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; const string &name = _args.get("name", 0, &_lock); @@ -1289,7 +1289,7 @@ static PyObject *_W_3(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "quantizeGrid", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; Grid &grid = *_args.getPtr>("grid", 0, &_lock); @@ -1365,7 +1365,7 @@ static PyObject *_W_4(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "quantizeGridVec3", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; Grid &grid = *_args.getPtr>("grid", 0, &_lock); diff --git a/extern/mantaflow/preprocessed/fileio/ioutil.cpp b/extern/mantaflow/preprocessed/fileio/ioutil.cpp index cf40d71fcc4..2c7ac7be00e 100644 --- a/extern/mantaflow/preprocessed/fileio/ioutil.cpp +++ b/extern/mantaflow/preprocessed/fileio/ioutil.cpp @@ -40,7 +40,7 @@ namespace Manta { #if defined(WIN32) || defined(_WIN32) static wstring stringToWstring(const char *str) { - const int length_wc = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0); + const int length_wc = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), nullptr, 0); wstring strWide(length_wc, 0); MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), &strWide[0], length_wc); return strWide; diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.cpp b/extern/mantaflow/preprocessed/fileio/mantaio.cpp index a03bd98d449..3048572261a 100644 --- a/extern/mantaflow/preprocessed/fileio/mantaio.cpp +++ b/extern/mantaflow/preprocessed/fileio/mantaio.cpp @@ -51,7 +51,7 @@ static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "load", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; const string &name = _args.get("name", 0, &_lock); @@ -118,7 +118,7 @@ static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds) FluidSolver *parent = _args.obtainParent(); bool noTiming = _args.getOpt("notiming", -1, 0); pbPreparePlugin(parent, "save", !noTiming); - PyObject *_retval = 0; + PyObject *_retval = nullptr; { ArgLocker _lock; const string &name = _args.get("name", 0, &_lock); diff --git a/extern/mantaflow/preprocessed/fileio/mantaio.h b/extern/mantaflow/preprocessed/fileio/mantaio.h index d3c7bb3ba6d..d49f4b1369d 100644 --- a/extern/mantaflow/preprocessed/fileio/mantaio.h +++ b/extern/mantaflow/preprocessed/fileio/mantaio.h @@ -93,8 +93,8 @@ template int readGrid4dUni(const std::string &name, Grid4d *grid, int readTslice = -1, - Grid4d *slice = NULL, - void **fileHandle = NULL); + Grid4d *slice = nullptr, + void **fileHandle = nullptr); void readGrid4dUniCleanup(void **fileHandle); template int writeGrid4dRaw(const std::string &name, Grid4d *grid); template int readGrid4dRaw(const std::string &name, Grid4d *grid); @@ -111,8 +111,12 @@ template int writeMdataUni(const std::string &name, MeshDataImpl *md template int readMdataUni(const std::string &name, MeshDataImpl *mdata); // Helpers -void getUniFileSize( - const std::string &name, int &x, int &y, int &z, int *t = NULL, std::string *info = NULL); +void getUniFileSize(const std::string &name, + int &x, + int &y, + int &z, + int *t = nullptr, + std::string *info = nullptr); void *safeGzopen(const char *filename, const char *mode); #if OPENVDB == 1 template void convertFrom(S &in, T *out); -- cgit v1.2.3