Changed semantics of CallAtEnd so that it calls installed procedures
in reversed order
This commit is contained in:
parent
61f0a89372
commit
c5345bf6ac
2 changed files with 5 additions and 7 deletions
|
@ -13,8 +13,8 @@ DEFINITION MODULE Epilogue;
|
||||||
PROCEDURE CallAtEnd(p: PROC): BOOLEAN;
|
PROCEDURE CallAtEnd(p: PROC): BOOLEAN;
|
||||||
(* Add procedure "p" to the list of procedures that must be executed when
|
(* Add procedure "p" to the list of procedures that must be executed when
|
||||||
the program finishes.
|
the program finishes.
|
||||||
When the program finishes, these procedures are executed in the order in
|
When the program finishes, these procedures are executed in the REVERSE
|
||||||
which they were added to the list.
|
order in which they were added to the list.
|
||||||
This procedure returns FALSE when there are too many procedures to be
|
This procedure returns FALSE when there are too many procedures to be
|
||||||
called (the list has a fixed size).
|
called (the list has a fixed size).
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
Author: Ceriel J.H. Jacobs
|
Author: Ceriel J.H. Jacobs
|
||||||
Version: $Header$
|
Version: $Header$
|
||||||
*/
|
*/
|
||||||
#define MAXPROCS 16
|
#define MAXPROCS 32
|
||||||
|
|
||||||
static int callindex = 0;
|
static int callindex = 0;
|
||||||
static int (*proclist[MAXPROCS])();
|
static int (*proclist[MAXPROCS])();
|
||||||
|
@ -17,7 +17,7 @@ _cleanup()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
for (i = 0; i < callindex; i++) {
|
for (i = callindex; --i >= 0;) {
|
||||||
(*proclist[i])();
|
(*proclist[i])();
|
||||||
}
|
}
|
||||||
callindex = 0;
|
callindex = 0;
|
||||||
|
@ -29,9 +29,7 @@ CallAtEnd(p)
|
||||||
if (callindex >= MAXPROCS) {
|
if (callindex >= MAXPROCS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
proclist[callindex++] = p;
|
||||||
proclist[callindex++] = p;
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue