Zeuthen: Writing a C library, part 1
Zeuthen: Writing a C library, part 1
Posted Jun 28, 2011 13:38 UTC (Tue) by cmccabe (guest, #60281)In reply to: Zeuthen: Writing a C library, part 1 by wahern
Parent article: Zeuthen: Writing a C library, part 1
I agree. If you write your library to abort when a memory allocation fails, you are forcing that policy on the library user. He may not want it.
Even if you choose not to handle out-of-memory errors, calling abort() doesn't seem like the right thing to do. Just because your library can't get its job done doesn't mean that the developer necessarily wants to bring down the whole application. Maybe that job was something extremely minor and we just want to keep going.
Posted Jun 28, 2011 15:48 UTC (Tue)
by nix (subscriber, #2304)
[Link] (1 responses)
Posted Jun 28, 2011 16:18 UTC (Tue)
by HelloWorld (guest, #56129)
[Link]
Zeuthen: Writing a C library, part 1
Zeuthen: Writing a C library, part 1
They can use longjump in the SIGABRT signal handler. But that probably doesn't make much of a difference, as a library that calls abort probably won't free allocated resources before it does, resulting in resource leaks.