I have several functions that suffer this issue, and I'm having a hard time making a design decision. The function(s) in question must create datastructures, and return them if successful. Of course, they could fail, and an error code would always be nice. So my choices are thus: (As I see it...)
Any opinions/knowledge of the (dis)advantages of each one? (Which one wins out in other programming projects?) Or am I just overcomplicating things?Code:// Return error code. (0 = success, nonzero = fail) int CreateThing(Thing **result); // Use NULL to indicate failure, but lose ability to differentiate between errors Thing *CreateThing(); // Return a thing, but have error code. Thing *CreateThing(int *error);