EasyManua.ls Logo

HP NonStop SQL/MP - Page 258

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C429847-008
10-60
Detailed Dynamic SQL Program
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; /* number of sqlvar entries */
991 short i; /* loop index */
992 char *buf_ptr; /* pointer to sqlvar buffer */
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 free( buf_ptr );
1002 }
1003
1004 free ( (char *) sqlda ); /* freeup the sqlda memory */
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 ); /* free input sqlda. */
1020 free_sqlda( sda_o ); /* free output sqlda. */
1021 sda_i = sda_o = NULL; /* init pointers */
1022
1023 if (cname_i != NULL)
1024 free ( (char *) cname_i ); /* free i/p names buffer */
1025 if (cname_o != NULL)
1026 free ( (char *) cname_o ); /* free o/p names buffer */
1027
1028 cname_i = cname_o = NULL; /* init pointers */
1029
1030 } /* cleanup */
1031
1032 main ()
1033 {
Example 10-8. Detailed Dynamic SQL Program (page 17 of 22)

Table of Contents

Related product manuals