From ecc925d2e5bc7f33289f6f40ca5f911050e8971c Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 5 Nov 2001 15:00:23 +0000 Subject: Added const qualifier to the 'cGH *' argument of some more IO functions. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOUtil/trunk@135 b32723a9-ab3a-4a60-88e2-2e5d99d7c17a --- src/CheckpointRecovery.c | 31 ++++++++++++++------------- src/ioutil_CheckpointRecovery.h | 46 ++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/CheckpointRecovery.c b/src/CheckpointRecovery.c index b512e50..7328a7f 100644 --- a/src/CheckpointRecovery.c +++ b/src/CheckpointRecovery.c @@ -146,7 +146,7 @@ int IOUtil_RegisterRecover (const char *name, @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @var basefilename @@ -177,7 +177,7 @@ int IOUtil_RegisterRecover (const char *name, @vio in @endvar @@*/ -void IOUtil_PrepareFilename (cGH *GH, +void IOUtil_PrepareFilename (const cGH *GH, const char *basefilename, char *fname, int called_from, @@ -597,7 +597,7 @@ int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH, @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @@ -605,7 +605,7 @@ int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH, @returndesc the allocated string or NULL @endreturndesc @@*/ -char *IOUtil_GetAllParameters (cGH *GH) +char *IOUtil_GetAllParameters (const cGH *GH) { int i, first; char *param; @@ -691,22 +691,23 @@ char *IOUtil_GetAllParameters (cGH *GH) @var parameters @vdesc the parameter string - @vtype char * + @vtype const char * @vio in @endvar @@*/ -void IOUtil_SetAllParameters (char *parameters) +void IOUtil_SetAllParameters (const char *parameters) { DECLARE_CCTK_PARAMETERS char *tmp, *nextparam, *avalue, *param; char oldchar; - char *name, *thorn_impl; + char *name, *thorn_impl, *parameter_string, *free_me; const char *thorn; - while (*parameters) + parameter_string = free_me = strdup (parameters); + while (*parameter_string) { - nextparam = parameters; + nextparam = parameter_string; while (*nextparam != '\n' && *nextparam) { nextparam++; @@ -714,14 +715,14 @@ void IOUtil_SetAllParameters (char *parameters) oldchar = *nextparam; *nextparam = 0; - tmp = parameters; + tmp = parameter_string; while (*tmp != ' ') { tmp++; } *tmp = 0; - param = parameters; + param = parameter_string; avalue = tmp + 3; name = thorn_impl = NULL; @@ -755,12 +756,14 @@ void IOUtil_SetAllParameters (char *parameters) } *nextparam = oldchar; - parameters = nextparam; - if (*parameters == '\n') + parameter_string = nextparam; + if (*parameter_string == '\n') { - parameters++; + parameter_string++; } } + + free (free_me); } diff --git a/src/ioutil_CheckpointRecovery.h b/src/ioutil_CheckpointRecovery.h index 0cbd949..8f9cde5 100644 --- a/src/ioutil_CheckpointRecovery.h +++ b/src/ioutil_CheckpointRecovery.h @@ -31,43 +31,43 @@ enum {CP_INITIAL_DATA, CP_EVOLUTION_DATA, CP_RECOVER_PARAMETERS, ************************************************************************/ /* create a checkpoint filename */ -void IOUtil_PrepareFilename (cGH *GH, - const char *basefilename, - char *fname, - int called_from, - int ioproc, - int file_unchunked); +void IOUtil_PrepareFilename (const cGH *GH, + const char *basefilename, + char *fname, + int called_from, + int ioproc, + int file_unchunked); /* register a new recovery method */ -int IOUtil_RegisterRecover (const char *name, - int (*func) (cGH *, const char *, int)); +int IOUtil_RegisterRecover (const char *name, + int (*func) (cGH *, const char *, int)); /* recover variables from a list of data files */ -void IOUtil_RecoverVarsFromDatafiles (cGH *GH, - const char *in_files, - const char *in_vars); +void IOUtil_RecoverVarsFromDatafiles (cGH *GH, + const char *in_files, + const char *in_vars); /* generic recovery routine called by other IO thorns */ -int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH, - const char *basefilename, - int called_from), - const char *fileExtension, - const char *fileType); +int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH, + const char *basefilename, + int called_from), + const char *fileExtension, + const char *fileType); /* return the parameter database as one single string */ -char *IOUtil_GetAllParameters (cGH *GH); +char *IOUtil_GetAllParameters (const cGH *GH); /* set all parameters contained in the given string */ -void IOUtil_SetAllParameters (char *parameters); +void IOUtil_SetAllParameters (const char *parameters); /* return true if this run was restarted from recovery, otherwise false */ -int IOUtil_RestartFromRecovery (const cGH *GH); +int IOUtil_RestartFromRecovery (const cGH *GH); /* print the checkpoint/recovery timings to stdout */ -void IOUtil_PrintTimings (const char *description, - int ntimers, - const int *timers, - const char *const *const timer_descriptions); +void IOUtil_PrintTimings (const char *description, + int ntimers, + const int *timers, + const char *const *const timer_descriptions); #ifdef __cplusplus } -- cgit v1.2.3