Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 2.1 KB

File metadata and controls

47 lines (37 loc) · 2.1 KB

conditional_stack_destroy

Location

src/fe_utils/conditional.c:43-52

Overview

Completely destroys a conditional stack by clearing all its elements and deallocating the stack structure itself.

Definition

void
conditional_stack_destroy(ConditionalStack cstack)

Detailed Description

This function provides complete cleanup of a conditional stack by first clearing all stack elements using conditional_stack_reset and then freeing the stack structure itself using the standard free() function. This is the proper way to deallocate a conditional stack that was created with conditional_stack_create. The function ensures that all memory associated with the stack, both the individual stack elements and the stack structure itself, is properly released to prevent memory leaks.

Parameters / Member Variables

  • cstack: ConditionalStack pointer to the conditional stack to be destroyed

Dependencies

  • Functions called/Symbols referenced:
  • Called from (representative examples):

Notes and Other Information

  • Should be called for every conditional stack created with conditional_stack_create to prevent memory leaks
  • The function assumes a valid (non-NULL) cstack pointer - passing NULL may cause undefined behavior
  • After calling this function, the cstack pointer becomes invalid and should not be used
  • This is the complement function to conditional_stack_create, completing the stack lifecycle
  • Used typically during cleanup phases of frontend utilities like psql and pgbench

Simplified Source

void conditional_stack_destroy(ConditionalStack cstack) {
    // Clear all stack elements first
    conditional_stack_reset(cstack);

    // Free the stack structure itself
    free(cstack);
}