I think I know the answer, but I should ask since I am about build a lot of code on my assumptions.
When I have a SUFaceRef object, in C++, I end up passing it to other functions quite often. I can pass it by value, or by reference. If I pass by value, I have a remote fear that I could end up with two objects, derived from the same object, but has the potential to diverge as it gets treated differently.
But then I think I am reassured by the “Ref” part of every C API object type. This indicates to me that every SUFaceRef is actually a reference to the Face object, and not the Face object itself. So in other words, after copying SUFaceRef, the “Reference” of the copied object still points to the original data.
So in other other words, the following two functions will always do the same thing to the same “object” (wherever it may be):
SUFaceRef add_loop_by_value(SUFaceRef face, SULoopInputRef loop) { // FaceRef is passed by value (copied)
// Initialise vertices here
SUFaceAddInnerLoop(face, vertices[0], &loop);
return face;
}
SUFaceRef add_loop_by_reference(SUFaceRef &face, SULoopInputRef loop) { // FaceRef is passed by reference (original copy passed)
// Initialise vertices here
SUFaceAddInnerLoop(face, vertices[0], &loop);
return face;
}
So in other other other words - I don’t need to worry about passing my C API objects by reference or by value in my C++ code? I can store multiple copies of a SUFaceRef object within other objects and they will all be working with/manipulating the same Face object?
Should I be reassured or gravely mistaken?