
KR> This adds result filtering so that an association only returns KR> instances that match the result class specified during the KR> query. Such an example is the following: I think this is a good idea. It allows our association handlers to ignore the result class (if so desired) knowing that std_association will do the result class filtering before returning to the client. Handlers could also look at the result_class field in std_assoc_info to optimize if desired or necessary. KR> + inst_list_init(&result_list); KR> + KR> + for (i = 0; list->list[i] != NULL; i++) { KR> + op = CMGetObjectPath(list->list[i], &s); KR> + if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) KR> + goto out; KR> + KR> + s = CMSetNameSpace(op, ns); KR> + if (s.rc != CMPI_RC_OK) KR> + goto out; KR> + KR> + if (!match_op(broker, op, filter_class)) KR> + continue; KR> + KR> + inst_list_add(&result_list, list->list[i]); KR> + c++; KR> + } KR> + KR> + inst_list_free(list); KR> + if (list->list != NULL) { KR> + CU_DEBUG("\tinst_list_free failed.\n"); KR> + goto out; KR> + } KR> + KR> + inst_list_init(list); KR> + KR> + for (i = 0; i <= c; i++) KR> + inst_list_add(list, result_list.list[i]); Instead of filling another list, and then copying it back, why not just make a copy of the incoming list and then copy matching instances back to the original? Something like this: struct inst_list tmp_list; tmp_list = *list; inst_list_init(list); for (items in tmp_list) { if (item is resultclass) inst_list_add(list, item); } inst_list_free(tmp_list); That should work, and only copy the needed instance pointers once, instead of running through the list twice. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com