News for hackers. Stuff that matters.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by sebcat on Thursday May 21, 2015 @12:29AM (#9580959)
A common way to solve that is to have a function argument point to a place where you want the result to end up, and always return FOO_ERROR or FOO_OK.

i.e.,

    int foo_new(foo_t **res);
    int foo_mutate_copy(foo_t *foo, bar_t *bar, foo_t **new_foo);
Instead of

    foo_t *foo_new(); // returns NULL on failure
    foo_t *foo_mutate_copy(foo_t *foo, bar_t *bar); // returns NULL on failure
I also like the Go way, just thought this way of doing things in C should be mentioned in the thread.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by voidlogic on Thursday May 28, 2015 @10:30AM (#9618370)
>using up your only return value and having to take pointer arguments when you would rather not.

I specifically mention the C way of doing things- but use you demonstrate it above. I was suggesting the Go way is superior.