rpm: reuse the rpmtd when possible

Use a single rpmtd object per operation, making sure it is properly
cleaned when needed. This slightly reduces the number of malloc/free's.
rpm: reuse the same iteration set

When resolving the requirements of a package, use the same set with the
results, instead of creating a new set and merging it with the results
set.