lr_free_parameter

Deletes a dynamic parameter at runtime, freeing its buffer.

int lr_free_parameter( const char *param );

Alphabetical Listing - C Language Utility Functions

Arguments

NameComments
param The name of the dynamic parameter.

The lr_free_parameter function frees the memory allocated at runtime for the specified parameter.

lr_free_parameter frees the memory for parameters created at runtime using functions such as web_reg_save_param or lr_save_string. For other functions that create parameters at runtime, see the Parameter Functions and the Web Correlation Functions for C. For similar functions in other protocols, see the reference for the specific protocol.

Return Values

This function returns 0 if it succeeds. Success means that both of the following are true:

  • The dynamic parameter by the specified name is found.
  • The memory allocated for the dynamic parameter is freed successfully.

Otherwise, the function returns a negative number.

Parameterization

You cannot use standard parameterization for any arguments in this function.

Example

In the first example, the lr_free_parameter function deallocates the memory saved for the parameter Name. When trying to access the parameter after deallocation, a warning is issued.

In the second example, an array of parameters is released in a loop. The array was created with web_reg_save_param where Ord=All

Example 1: Releasing a single parameter

// Create the parameter Name

lr_save_string("Fitzwilliam", "Name");

 

// Try to evaluate the string "Name" with parameter delimiters

    lr_output_message(lr_eval_string("{Name}"));

 // Free the memory allocated for the dynamic parameter "Name"

    lr_free_parameter("Name");

 // Try to re-evaluate the string "Name" with parameter delimiters

    lr_output_message(lr_eval_string("{Name}"));

return 0;

 

Example: Output:

vuser_init.c(9): Notify: Saving Parameter "Name = Fitzwilliam".

vuser_init.c(14): Notify: Parameter Substitution: parameter "Name" = "Fitzwilliam"

vuser_init.c(14): Fitzwilliam

vuser_init.c(18): Notify: Freeing Parameter 'Name'.

vuser_init.c(22): Warning: The string 'Name' with parameter delimiters is not a parameter.

vuser_init.c(22): {Name}

Example 2: Releasing an array of parameters

web_reg_save_param("test",

    "LB=\"",

    "RB=\" ",

    "Ord=All",

    LAST);

     

... any action function

 

i=atoi(lr_eval_string("{test_count}"));

while(i>0){

    sprintf(buff, "test_%d", i); //Add index after "test_"

    lr_free_parameter(buff); //Free parameter from array

    i--;

}