*/
msg_file_t MSG_file_open(const char* fullpath, void* data)
{
- char name[2048];
+ char *name;
msg_file_priv_t priv = xbt_new(s_msg_file_priv_t, 1);
priv->data = data;
priv->fullpath = xbt_strdup(fullpath);
priv->simdata = xbt_new0(s_simdata_file_t,1);
priv->simdata->smx_file = simcall_file_open(fullpath, MSG_host_self());
- sprintf(name, "%s:%s",MSG_host_get_name(MSG_host_self()),fullpath);
+ name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),fullpath);
xbt_lib_set(file_lib, name, MSG_FILE_LEVEL, priv);
msg_file_t fd = (msg_file_t) xbt_lib_get_elm_or_null(file_lib, name);
__MSG_file_get_info(fd);
-
+ xbt_free(name);
return fd;
}
-/**
- * \brief Frees private data of a file (internal call only)
- */
-void __MSG_file_priv_free(msg_file_priv_t priv)
-{
- xbt_free(&priv->simdata->smx_file);
- free(priv);
-}
-
/** \ingroup msg_file_management
* \brief Close the file
*
*/
int MSG_file_close(msg_file_t fd)
{
- char name[2048];
+ char *name;
msg_file_priv_t priv = MSG_file_priv(fd);
+ if (priv->data)
+ xbt_free(priv->data);
+
int res = simcall_file_close(priv->simdata->smx_file, MSG_host_self());
- sprintf(name, "%s:%s",MSG_host_get_name(MSG_host_self()),priv->fullpath);
+ name = bprintf("%s:%i:%s",MSG_host_get_name(MSG_host_self()),MSG_process_self_PID(),priv->fullpath);
xbt_lib_unset(file_lib, name, MSG_FILE_LEVEL, 1);
+ xbt_free(name);
return res;
}
xbt_dict_set(MSG_storage_get_properties(storage), name, value,free_ctn);
}
+/** \ingroup m_storage_management
+ * \brief Returns the value of a given storage property
+ *
+ * \param storage a storage
+ * \param name a property name
+ * \return value of a property (or NULL if property not set)
+ */
+const char *MSG_storage_get_property_value(msg_storage_t storage, const char *name)
+{
+ return xbt_dict_get_or_null(MSG_storage_get_properties(storage), name);
+}
+
+
/** \ingroup msg_storage_management
* \brief Finds a msg_storage_t using its name.
* \param name the name of a storage