PROCEDURE CallAtEnd(p: PROC): BOOLEAN;
(* Add procedure "p" to the list of procedures that must be executed when
the program finishes.
- When the program finishes, these procedures are executed in the order in
- which they were added to the list.
+ When the program finishes, these procedures are executed in the REVERSE
+ order in which they were added to the list.
This procedure returns FALSE when there are too many procedures to be
called (the list has a fixed size).
*)
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
-#define MAXPROCS 16
+#define MAXPROCS 32
static int callindex = 0;
static int (*proclist[MAXPROCS])();
{
register int i;
- for (i = 0; i < callindex; i++) {
+ for (i = callindex; --i >= 0;) {
(*proclist[i])();
}
callindex = 0;
if (callindex >= MAXPROCS) {
return 0;
}
- else {
- proclist[callindex++] = p;
- }
+ proclist[callindex++] = p;
return 1;
}