Just use a pointer, pass a pointer to what you want to alter, and do it that way. (Or a pointer to a pointer, and allocate the data inside the function.)
Quzah.
Just use a pointer, pass a pointer to what you want to alter, and do it that way. (Or a pointer to a pointer, and allocate the data inside the function.)
Quzah.
Hope is the first step on the road to disappointment.
Or pass a pointer to a pointer if you don't feel like returning. It doesn't matter how you do it really. It's just a matter of preference.
Quzah.
Hope is the first step on the road to disappointment.
Passing in a destination pointer only works if all your objects are the same size (so that the caller knows how big a malloc to do, or whatever). Between returning a pointer to a new data and passing in a double pointer, there's not a lot of difference and I'm pretty sure I've seen both used a fair bit. The second is a little more flexible if there's something else you want to return, like a size or an error code or something; the first allows nesting functions if that's something you might see yourself doing.
Thanks for the help. Also thanks for pointing out that I need a pointer to a pointer if I allocate the data.
I said all of that in the first reply to this thread. And in pretty much every other reply to this thread as well...
Quzah.
Hope is the first step on the road to disappointment.