diff options
Diffstat (limited to 'src/H5FDlog.c')
-rw-r--r-- | src/H5FDlog.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 0e50df0..f649bc4 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -252,8 +252,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the log driver. - * Failure: Negative. + * Return: Success: The driver ID for the log driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -265,7 +265,7 @@ H5FD_log_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); @@ -329,16 +329,24 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - /* This shallow copy is correct! The string will be properly - * copied deep down in the H5P code. + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + + /* Duplicate the log file string + * A little wasteful, since this string will just be copied later, but + * passing it in as a pointer sets off a chain of impossible-to-resolve + * const cast warnings. */ - fa.logfile = (char *)logfile; + if(logfile != NULL && NULL == (fa.logfile = H5MM_xstrdup(logfile))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to copy log file name") fa.flags = flags; fa.buf_size = buf_size; ret_value = H5P_set_driver(plist, H5FD_LOG, &fa); done: + if(fa.logfile) + H5MM_free(fa.logfile); + FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_log() */ |