* Pop old arguments when exiting a recursive call. * * Note: the idea here is to adjust the proc's callstack state before doing * anything that could possibly fail. In event of any error, we want the * callstack to look like we've done the pop. Leaking a bit of memory is * tolerable. */
| 644 | * tolerable. |
| 645 | */ |
| 646 | static void |
| 647 | PLy_global_args_pop(PLyProcedure *proc) |
| 648 | { |
| 649 | Assert(proc->calldepth > 0); |
| 650 | /* We only need to pop if we were already inside some active call */ |
| 651 | if (proc->calldepth > 1) |
| 652 | { |
| 653 | PLySavedArgs *ptr = proc->argstack; |
| 654 | |
| 655 | /* Pop the callstack */ |
| 656 | Assert(ptr != NULL); |
| 657 | proc->argstack = ptr->next; |
| 658 | proc->calldepth--; |
| 659 | |
| 660 | /* Restore argument values, then free ptr */ |
| 661 | PLy_function_restore_args(proc, ptr); |
| 662 | } |
| 663 | else |
| 664 | { |
| 665 | /* Exiting call depth 1 */ |
| 666 | Assert(proc->argstack == NULL); |
| 667 | proc->calldepth--; |
| 668 | |
| 669 | /* |
| 670 | * We used to delete the named arguments (but not "args") from the |
| 671 | * proc's globals dict when exiting the outermost call level for a |
| 672 | * function. This seems rather pointless though: nothing can see the |
| 673 | * dict until the function is called again, at which time we'll |
| 674 | * overwrite those dict entries. So don't bother with that. |
| 675 | */ |
| 676 | } |
| 677 | } |
| 678 | |
| 679 | /* |
| 680 | * Memory context deletion callback for cleaning up a PLySRFState. |
no test coverage detected