* PQclear - * free's the memory associated with a PGresult */
| 715 | * free's the memory associated with a PGresult |
| 716 | */ |
| 717 | void |
| 718 | PQclear(PGresult *res) |
| 719 | { |
| 720 | PGresult_data *block; |
| 721 | int i; |
| 722 | |
| 723 | if (!res) |
| 724 | return; |
| 725 | |
| 726 | for (i = 0; i < res->nEvents; i++) |
| 727 | { |
| 728 | /* only send DESTROY to successfully-initialized event procs */ |
| 729 | if (res->events[i].resultInitialized) |
| 730 | { |
| 731 | PGEventResultDestroy evt; |
| 732 | |
| 733 | evt.result = res; |
| 734 | (void) res->events[i].proc(PGEVT_RESULTDESTROY, &evt, |
| 735 | res->events[i].passThrough); |
| 736 | } |
| 737 | free(res->events[i].name); |
| 738 | } |
| 739 | |
| 740 | if (res->events) |
| 741 | free(res->events); |
| 742 | |
| 743 | /* Free all the subsidiary blocks */ |
| 744 | while ((block = res->curBlock) != NULL) |
| 745 | { |
| 746 | res->curBlock = block->next; |
| 747 | free(block); |
| 748 | } |
| 749 | |
| 750 | /* Free the top-level tuple pointer array */ |
| 751 | if (res->tuples) |
| 752 | free(res->tuples); |
| 753 | |
| 754 | /* zero out the pointer fields to catch programming errors */ |
| 755 | res->attDescs = NULL; |
| 756 | res->tuples = NULL; |
| 757 | res->paramDescs = NULL; |
| 758 | res->errFields = NULL; |
| 759 | res->events = NULL; |
| 760 | res->nEvents = 0; |
| 761 | /* res->curBlock was zeroed out earlier */ |
| 762 | |
| 763 | if (res->extras) |
| 764 | free(res->extras); |
| 765 | res->extraslen = 0; |
| 766 | res->extras = NULL; |
| 767 | res->extraType = PGExtraTypeNone; |
| 768 | |
| 769 | if (res->waitGxids) |
| 770 | free(res->waitGxids); |
| 771 | res->waitGxids = NULL; |
| 772 | res->nWaits = 0; |
| 773 | |
| 774 | /* Free the PGresult structure itself */ |
no outgoing calls