*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
struct t_pstack *prev;
} t_pstack;
-static t_pstack *pstack = NULL;
+static t_pstack *pstack = nullptr;
static bool bUnbuffered = false;
static int s_maxBackupCount = 0;
const DataFileFinder &getLibraryFileFinder()
{
- if (g_libFileFinder != NULL)
+ if (g_libFileFinder != nullptr)
{
return *g_libFileFinder;
}
if (count < 0)
{
const char *env = getenv("GMX_MAXBACKUP");
- if (env != NULL)
+ if (env != nullptr)
{
// TODO: Check that the value is converted properly.
- count = strtol(env, NULL, 10);
+ count = strtol(env, nullptr, 10);
if (count < 0)
{
count = 0;
tMPI_Thread_mutex_lock(&pstack_mutex);
ps = pstack;
- if (ps == NULL)
+ if (ps == nullptr)
{
- if (fp != NULL)
+ if (fp != nullptr)
{
ret = fclose(fp);
}
}
else if (ps->fp == fp)
{
- if (fp != NULL)
+ if (fp != nullptr)
{
ret = pclose(fp);
}
}
else
{
- while ((ps->prev != NULL) && (ps->prev->fp != fp))
+ while ((ps->prev != nullptr) && (ps->prev->fp != fp))
{
ps = ps->prev;
}
- if ((ps->prev != NULL) && ps->prev->fp == fp)
+ if ((ps->prev != nullptr) && ps->prev->fp == fp)
{
- if (ps->prev->fp != NULL)
+ if (ps->prev->fp != nullptr)
{
ret = pclose(ps->prev->fp);
}
}
else
{
- if (fp != NULL)
+ if (fp != nullptr)
{
ret = fclose(fp);
}
tMPI_Thread_mutex_lock(&pstack_mutex);
t_pstack *ps = pstack;
- while (ps != NULL)
+ while (ps != nullptr)
{
if (ps->fp == fp)
{
sprintf(buf, "uncompress -c < %s", fn);
fprintf(stderr, "Going to execute '%s'\n", buf);
- if ((fp = popen(buf, mode)) == NULL)
+ if ((fp = popen(buf, mode)) == nullptr)
{
gmx_open(fn);
}
sprintf(buf, "gunzip -c < %s", fn);
fprintf(stderr, "Going to execute '%s'\n", buf);
- if ((fp = popen(buf, mode)) == NULL)
+ if ((fp = popen(buf, mode)) == nullptr)
{
gmx_open(fn);
}
{
FILE *test;
- if (fname == NULL)
+ if (fname == nullptr)
{
return FALSE;
}
test = fopen(fname, "r");
- if (test == NULL)
+ if (test == nullptr)
{
/*Windows doesn't allow fopen of directory - so we need to check this seperately */
#if GMX_NATIVE_WINDOWS
#ifdef SKIP_FFOPS
return fopen(file, mode);
#else
- FILE *ff = NULL;
- char buf[256], *bufsize = 0, *ptr;
+ FILE *ff = nullptr;
+ char buf[256], *bufsize = nullptr, *ptr;
gmx_bool bRead;
int bs;
- if (file == NULL)
+ if (file == nullptr)
{
- return NULL;
+ return nullptr;
}
if (mode[0] == 'w')
strcpy(buf, file);
if (!bRead || gmx_fexist(buf))
{
- if ((ff = fopen(buf, mode)) == NULL)
+ if ((ff = fopen(buf, mode)) == nullptr)
{
gmx_file(buf);
}
/* Check whether we should be using buffering (default) or not
* (for debugging)
*/
- if (bUnbuffered || ((bufsize = getenv("GMX_LOG_BUFFER")) != NULL))
+ if (bUnbuffered || ((bufsize = getenv("GMX_LOG_BUFFER")) != nullptr))
{
/* Check whether to use completely unbuffered */
if (bUnbuffered)
}
else
{
- bs = strtol(bufsize, NULL, 10);
+ bs = strtol(bufsize, nullptr, 10);
}
if (bs <= 0)
{
- setbuf(ff, NULL);
+ setbuf(ff, nullptr);
}
else
{
}
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
- return NULL;
+ return nullptr;
}
FILE *low_libopen(const char *file, gmx_bool bFatal)
return fp;
}
GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
- return NULL;
+ return nullptr;
}
char *gmxlibfn(const char *file)
FILE *gmx_fopen_temporary(char *buf)
{
int i, len;
- FILE *fpout = NULL;
+ FILE *fpout = nullptr;
if ((len = strlen(buf)) < 7)
{
gmx_fatal(FARGS, "Error creating temporary file %s: %s", buf,
strerror(errno));
}
- if ((fpout = fdopen(fd, "w")) == NULL)
+ if ((fpout = fdopen(fd, "w")) == nullptr)
{
gmx_fatal(FARGS, "Cannot open temporary file %s", buf);
}
{
/* the full copy buffer size: */
#define FILECOPY_BUFSIZE (1<<16)
- FILE *in = NULL;
- FILE *out = NULL;
+ FILE *in = nullptr;
+ FILE *out = nullptr;
char *buf;
snew(buf, FILECOPY_BUFSIZE);
#else
char *pdum = getcwd(buffer, size);
#endif
- if (pdum == NULL)
+ if (pdum == nullptr)
{
gmx_fatal(FARGS, "Cannot get working directory. Reason: %s",
strerror(errno));