* restorePsetInfo: restore *popt from the previously-saved copy *save, * then free *save. */
| 4708 | * then free *save. |
| 4709 | */ |
| 4710 | void |
| 4711 | restorePsetInfo(printQueryOpt *popt, printQueryOpt *save) |
| 4712 | { |
| 4713 | /* Free all the old data we're about to overwrite the pointers to. */ |
| 4714 | |
| 4715 | /* topt.line_style points to const data that need not be duplicated */ |
| 4716 | if (popt->topt.fieldSep.separator) |
| 4717 | free(popt->topt.fieldSep.separator); |
| 4718 | if (popt->topt.recordSep.separator) |
| 4719 | free(popt->topt.recordSep.separator); |
| 4720 | if (popt->topt.tableAttr) |
| 4721 | free(popt->topt.tableAttr); |
| 4722 | if (popt->nullPrint) |
| 4723 | free(popt->nullPrint); |
| 4724 | if (popt->title) |
| 4725 | free(popt->title); |
| 4726 | |
| 4727 | /* |
| 4728 | * footers and translate_columns are never set in psql's print settings, |
| 4729 | * so we needn't write code to duplicate them. |
| 4730 | */ |
| 4731 | Assert(popt->footers == NULL); |
| 4732 | Assert(popt->translate_columns == NULL); |
| 4733 | |
| 4734 | /* Now we may flat-copy all the fields, including pointers. */ |
| 4735 | memcpy(popt, save, sizeof(printQueryOpt)); |
| 4736 | |
| 4737 | /* Lastly, free "save" ... but its sub-structures now belong to popt. */ |
| 4738 | free(save); |
| 4739 | } |
| 4740 | |
| 4741 | static const char * |
| 4742 | pset_bool_string(bool val) |
no outgoing calls
no test coverage detected