ossp-pkg/cfg/cfg_data.c 1.2 -> 1.3
--- cfg_data.c 2002/07/10 12:00:23 1.2
+++ cfg_data.c 2002/07/10 19:26:32 1.3
@@ -84,6 +84,19 @@
return CFG_OK;
}
+cfg_rc_t cfg_data_copy(cfg_data_t *data, cfg_data_t *copy)
+{
+ cfg_rc_t rc;
+
+ if (data == NULL || copy == NULL)
+ return CFG_ERR_ARG;
+ copy->type = data->type;
+ copy->ctrl = data->ctrl;
+ if ((rc = data->ctrl(data, CFG_DATA_CTRL_CLONE, copy)) != CFG_OK)
+ return rc;
+ return CFG_OK;
+}
+
cfg_rc_t cfg_data_clone(cfg_data_t *data, cfg_data_t **clone)
{
cfg_rc_t rc;
@@ -92,12 +105,8 @@
return CFG_ERR_ARG;
if ((*clone = (cfg_data_t *)malloc(sizeof(cfg_data_t))) == NULL)
return CFG_ERR_SYS;
- (*clone)->type = data->type;
- (*clone)->ctrl = data->ctrl;
- if ((rc = data->ctrl(data, CFG_DATA_CTRL_CLONE, *clone)) != CFG_OK) {
- free(*clone);
+ if ((rc = cfg_data_copy(data, *clone)) != CFG_OK)
return rc;
- }
return CFG_OK;
}
|
|