| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Rakudo
Revision: 30769
Author: jonathan
Date: 04 Sep 2008 17:26:45
Changes:[rakudo] Free allocated memory in Perl6MultiSub, so we don't leak.
Files:| ... | ...@@ -360,6 +360,13 @@ | |
| 360 | 360 | result_pos++; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | /* Free memory associated with the graph. */ | |
| 364 | for (i = 0; i < num_candidates; i++) { | |
| 365 | mem_sys_free(graph[i]->edges); | |
| 366 | mem_sys_free(graph[i]); | |
| 367 | } | |
| 368 | mem_sys_free(graph); | |
| 369 | ||
| 363 | 370 | return result; |
| 364 | 371 | } |
| 365 | 372 | |
| ... | ...@@ -580,6 +587,20 @@ | |
| 580 | 587 | |
| 581 | 588 | */ |
| 582 | 589 | VTABLE void destroy() { |
| 590 | /* If we built a sorted candidate list, free that. */ | |
| 591 | candidate_info **candidates = NULL; | |
| 592 | GETATTR_Perl6MultiSub_candidates_sorted(interp, SELF, candidates); | |
| 593 | if (candidates) { | |
| 594 | candidate_info **cur_candidate = candidates; | |
| 595 | while (cur_candidate[0] != NULL || cur_candidate[1] != NULL) { | |
| 596 | if (*cur_candidate) | |
| 597 | mem_sys_free(*cur_candidate); | |
| 598 | cur_candidate++; | |
| 599 | } | |
| 600 | mem_sys_free(candidates); | |
| 601 | } | |
| 602 | ||
| 603 | /* Free memory associated with this PMC's underlying struct. */ | |
| 583 | 604 | mem_sys_free(PMC_data(SELF)); |
| 584 | 605 | PMC_data(SELF) = NULL; |
| 585 | 606 | } |