]> diplodocus.org Git - nmh/blob - sbr/done.c
Fix invalid pointer arithmetic.
[nmh] / sbr / done.c
1 /* done.c -- terminate the program
2 *
3 * This code is Copyright (c) 2002, by the authors of nmh. See the
4 * COPYRIGHT file in the root directory of the nmh distribution for
5 * complete copyright information.
6 */
7
8 #include <h/mh.h>
9
10 static void (*altexit)(int) NORETURN = exit;
11
12 /* set_done changes the path of done() from exit(3), or back to exit(3).
13 * Anything else will work, but a standard-error warning will report the
14 * old non-exit() value has been trampled. */
15 void
16 set_done(void (*new)(int) NORETURN)
17 {
18 generic_pointer gpo, gpn;
19
20 if (altexit != exit && new != exit) {
21 gpo.f = (void (*)(void))altexit;
22 gpn.f = (void (*)(void))new;
23 inform("altexit trampled: %p %p", gpo.v, gpn.v);
24 }
25 altexit = new;
26 }
27
28 void NORETURN
29 done(int status)
30 {
31 (*altexit)(status);
32 }