Dan Smith wrote:
JG> +CMPIStatus cu_dup_instance(const CMPIBroker *broker,
JG> + CMPIInstance *src,
JG> + CMPIInstance **dest)
JG> +{
JG> + CMPIStatus s = {CMPI_RC_OK, NULL};
JG> + CMPIObjectPath *ref;
JG> +
JG> + ref = CMGetObjectPath(src, NULL);
JG> + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(ref)) {
JG> + cu_statusf(broker, &s,
JG> + CMPI_RC_ERR_FAILED,
JG> + "Could not get objectpath from instance");
JG> + goto out;
JG> + }
JG> +
JG> + *dest = NULL;
Why set it to NULL and then set it to the instance right after this?
I think I was going with "not sure what *dest becomes if NewInstance"
fails, and so I figured better safe than sorry. I'd rather have it NULL
than undefined.
JG> + *dest = CMNewInstance(broker, ref, &s);
JG> +
JG> + out:
JG> + return s;
JG> +}
What about all the properties of the instance? This gets a new
instance structure, yes, but all it has is an object path. Maybe that
is all you need at the moment, but I don't think this does what other
consumers of the library would think by the name :)
It should be easy to loop through all the properties and copy them
over. It will look similar to the array copy/filter code in Kaitlin's
libcmpiutil CO patch.
I'm pleading CIM ignorance on this one. I thought the ObjectPath
encompassed the properties, and thought that my testing showed it
happening (I don't manually move the JobState over but it is est), but I
could have been wrong.
--
-Jay