hzeller / gmrender-resurrect

Resource efficient UPnP/DLNA renderer, optimal for Raspberry Pi, CuBox or a general MediaServer. Fork of GMediaRenderer to add some features to make it usable.
GNU General Public License v2.0
839 stars 204 forks source link

Removed the gotos from upnp_device.c #24

Closed ghost closed 11 years ago

ghost commented 11 years ago

Don't know if this will appeal to you, but let's give it a try.

I've pulled out the payload/paywork from the resource allocation/deallocation logic.

My personal preference (yours may be different) is to allocate required resources, call for someone else to do the real work and when I know the outcome of that, I deal with freeing resources.

If I fail to allocate the resources, I can easily bail out. If the real pay-work fails, I'll know about it and I can deal with it.

No more gotos. :-)

I think this diff is hard to read. Kinda out of sequence. You may or may not want to use your printer before deciding how to deal with my proposal.

hzeller commented 11 years ago

I like it, and I agree with your approach. One bug snug into it while doing the cleanup: there is a free(buf) of a file that is to be served by the webserver, that needs to go; other than that, looks ready to merge.

ghost commented 11 years ago

Very good catch. Thanks a lot. Could have become nasty to find that one.

hzeller commented 11 years ago

Thanks. I personally stick to 80 characters as well, but this just fits.