News for hackers. Stuff that matters.
Re:Banned C standard library functions in Git source code by crankylinuxuser on Sunday August 25, 2019 @11:49AM (#20793578)
And that's the perfect usage for goto. Error catching and jump to fail block...
Re:Banned C standard library functions in Git source code by johannes1234321 on Sunday August 25, 2019 @01:26PM (#20794181)
Goto requires the fail block to be in the same frame. It can be a working error strategy for failing critical errors in such a way from a failing module. You have to be aware that lots of stuff is prone to leak (which can be avoided by i.e. using some memory arena) and locks/mutexes/... might be in unclear state, so code has to be aware of that.
Re:Banned C standard library functions in Git source code by userbinator on Sunday August 25, 2019 @01:57PM (#20794410)
The destination of the goto is usually the clean-up code.
Re:Banned C standard library functions in Git source code by johannes1234321 on Sunday August 25, 2019 @06:46PM (#20796116)
That's nice for the single frame.

Let's take the example of PostgreSQL, which was mentioned in this thread: A potential implementation (I have no knowledge of pgsql internals) might be that for a single user session all memory is from a single arena, all locks and other handles are tied to the session handle, then it can be an efficient strategy to longjmp out on a critical error (i.e. IO error) and clean the arena as well as things tied to the session. instead of bubbling this up through all frames.

Re:Banned C standard library functions in Git source code by Mikhail_Edoshin on Monday August 26, 2019 @02:46AM (#20797919)
It's a different use case. There was a nice article[1] about exceptions in plain C with setjmp and longjmp.

[1] http://www.on-time.com/ddj0011.htm