HP NonStop SQL/MP Programming Manual page 258

For c
Table of Contents

Advertisement

Dynamic SQL Operations
Example 10-8. Detailed Dynamic SQL Program (page 17 of 22)
976
977
/* *************************************************** */
978
/* FUNCTION free_sqlda
979
/* This function accepts an sqlda as a parameter and
980
/* frees all memory that was allocated for the data
981
/* buffers (pointed to as sqlvar[i].var_ptr)
982
/* and for the sqlda and sqlvar entries
983
/*
984
/* The function assumes that if a valid sqlda is
985
/* passed, then sqlda.num_entries has a valid value
986
/*
987
/* *************************************************** */
988
int free_sqlda ( sqldaptr sqlda)
989
{ /* begin free_sqlda */
990
int num_entries;
991
short i;
992
char *buf_ptr;
993
994
/* sanity check */
995
if (sqlda == NULL)
996
return (0);
997
998
num_entries = sqlda->num_entries;
999
for (i = 0; i < num_entries; i++)
1000
{ if ( (buf_ptr = (char *) sqlda->sqlvar[i].var_ptr) != NULL)
1001
1002
}
1003
1004
free ( (char *) sqlda );
1005
1006
return (0);
1007
1008
} /* end free_sqlda */
1009
1010
/* ***************************************************** */
1011
/* FUNCTION cleanup
1012
/* This function frees up the allocated memory for the
1013
/* input and output sqldas and names buffers and the
1014
/* data buffers allocated for the sqldas
1015
/* ***************************************************** */
1016
void cleanup ()
1017
{
/* cleanup */
1018
1019
free_sqlda( sda_i );
1020
free_sqlda( sda_o );
1021
sda_i = sda_o = NULL;
1022
1023
if (cname_i != NULL)
1024
free ( (char *) cname_i );
1025
if (cname_o != NULL)
1026
free ( (char *) cname_o );
1027
1028
cname_i = cname_o = NULL; /* init pointers */
1029
1030
} /* cleanup */
1031
1032
main ()
1033
{
HP NonStop SQL/MP Programming Manual for C—429847-008
/* number of sqlvar entries
/* loop index
/* pointer to sqlvar buffer
free( buf_ptr );
/* freeup the sqlda memory */
/* free input sqlda.
/* free output sqlda.
/* init pointers
/* free i/p names buffer
/* free o/p names buffer
10-60
Detailed Dynamic SQL Program
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

Table of Contents