Commit 1a130ddd authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Refactor cdfDefHistory-related functions.

parent ad42d491
......@@ -8271,15 +8271,13 @@ static void cdfDefLocalAtts(stream_t *streamptr)
#endif
void cdfDefHistory(stream_t *streamptr, int size, char *history)
{
#if defined (HAVE_LIBNETCDF)
int ncid;
ncid = streamptr->fileID;
void cdfDefHistory(stream_t *streamptr, int size, const char *history)
{
int ncid = streamptr->fileID;
cdf_put_att_text(ncid, NC_GLOBAL, "history", (size_t) size, history);
#endif
}
#endif
int cdfInqHistorySize(stream_t *streamptr)
......
......@@ -5,7 +5,7 @@ void cdfDefVars(stream_t *streamptr);
void cdfDefTimestep(stream_t *streamptr, int tsID);
int cdfInqTimestep(stream_t *streamptr, int tsID);
int cdfInqContents(stream_t *streamptr);
void cdfDefHistory(stream_t *streamptr, int size, char *history);
void cdfDefHistory(stream_t *streamptr, int size, const char *history);
int cdfInqHistorySize(stream_t *streamptr);
void cdfInqHistoryString(stream_t *streamptr, char *history);
......
......@@ -10,9 +10,8 @@
void streamDefHistory(int streamID, int length, const char *history)
{
stream_t *streamptr;
streamptr = stream_to_pointer(streamID);
#ifdef HAVE_LIBNETCDF
stream_t *streamptr = stream_to_pointer(streamID);
if ( streamptr->filetype == FILETYPE_NC ||
streamptr->filetype == FILETYPE_NC2 ||
......@@ -26,12 +25,17 @@ void streamDefHistory(int streamID, int length, const char *history)
len = strlen(history);
if ( len )
{
/* FIXME: what's the point of strdupx? Why not use
* history argument directly? */
histstring = strdupx(history);
cdfDefHistory(streamptr, length, histstring);
free(histstring);
}
}
}
#else
(void)streamID; (void)length; (void)history;
#endif
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment