|
From: Gareth S B. <bes...@us...> - 2005-05-13 22:55:59
|
Update of /cvsroot/sblim/cmpi-tests/cmpi-instancetest/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28729/cmpi-instancetest/src Modified Files: TST_InstanceTest.c Log Message: CMClone/CMRelease fixes Index: TST_InstanceTest.c =================================================================== RCS file: /cvsroot/sblim/cmpi-tests/cmpi-instancetest/src/TST_InstanceTest.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- TST_InstanceTest.c 12 May 2005 00:53:19 -0000 1.2 +++ TST_InstanceTest.c 13 May 2005 22:55:50 -0000 1.3 @@ -1116,8 +1116,9 @@ /* Check that the instance's class is the same as the reference class */ if (strcmp(CMGetCharPtr(CMGetClassName(objectpath,NULL)), classname) != 0) continue; - /* Return this instance */ - CMReturnInstance(results, instances[i]); + + /* Return a copy of this instance (all results are free'd on CMReturnDone) */ + CMReturnInstance(results, CMClone(instances[i],NULL)); found++; } @@ -1160,7 +1161,9 @@ CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Requested instance not found"); goto exit; } - CMReturnInstance(results, instances[index]); + + /* Return a copy of this instance (all results are free'd on CMReturnDone) */ + CMReturnInstance(results, CMClone(instances[index],NULL)); /* Finished */ CMReturnDone(results); @@ -1233,9 +1236,13 @@ goto exit; } - /* To be safe, make a copy of the new instance and replace the old instance */ + /* Remove the old instance from the internal list of instances */ + CMRelease(instances[index]); + + /* Replace it with a copy of the new instance */ newinstancecopy = CMClone(newinstance, &status); if ((status.rc != CMPI_RC_OK) || CMIsNullObject(newinstance)) { + instances[index] = NULL; _OSBASE_TRACE(1,("%s:SetInstance() CMClone() failed", _PROVIDERNAME)); CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERROR_SYSTEM, "CMClone() failed"); goto exit; @@ -1358,6 +1365,9 @@ CMSetStatusWithChars(_BROKER, &status, CMPI_RC_ERR_NOT_FOUND, "Requested instance not found"); goto exit; } + + /* Remove the instance from the internal list of instances */ + CMRelease(instances[index]); instances[index] = NULL; /* Finished */ @@ -1463,7 +1473,10 @@ free(_PROVIDERNAME); /* Free entries in the instances list */ - for (i=0; i<sizeinstances; i++) free(instances[i]); + for (i=0; i<sizeinstances; i++) { + if (instances[i] != NULL) CMRelease(instances[i]); + free(instances[i]); + } /* Finished */ exit: @@ -1483,7 +1496,7 @@ CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations */ CMPIInstance * newinstance = NULL; /* New instance to add to the internal list */ CMPIObjectPath * newobjectpath = NULL; /* New object path for each new instance */ - int instancenum = 2; /* Number of instances to populate the internal list */ + int instancenum = 1; /* Number of instances to populate the internal list */ _OSBASE_TRACE(1,("%s:Initialize() called", self->ft->miName)); |