00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <grass/sqlp.h>
00024
00025
00026 SQLPSTMT * sqpInitStmt( void )
00027 {
00028 SQLPSTMT *st;
00029
00030 st = (SQLPSTMT *) calloc (1, sizeof (SQLPSTMT));
00031
00032 return (st);
00033 }
00034
00035
00036 int sqpAllocCol(SQLPSTMT *st, int n)
00037 {
00038 int i;
00039
00040 if ( n > st->aCol )
00041 {
00042 n += 15;
00043 st->Col = (SQLPVALUE *) realloc ( st->Col, n * sizeof(SQLPVALUE));
00044 st->ColType = (int *) realloc ( st->ColType, n * sizeof(int));
00045 st->ColWidth = (int *) realloc ( st->ColWidth, n * sizeof(int));
00046 st->ColDecim = (int *) realloc ( st->ColDecim, n * sizeof(int));
00047
00048 for (i = st->nCol; i < n; i++)
00049 {
00050 st->Col[i].s = NULL ;
00051 }
00052
00053 st->aCol = n;
00054 }
00055 return (1);
00056 }
00057
00058
00059 int sqpAllocVal(SQLPSTMT *st, int n)
00060 {
00061 int i;
00062
00063 if ( n > st->aVal )
00064 {
00065 n += 15;
00066 st->Val = (SQLPVALUE *) realloc ( st->Val, n * sizeof(SQLPVALUE));
00067
00068 for (i = st->nVal; i < n; i++)
00069 {
00070 st->Val[i].s = NULL ;
00071 }
00072
00073 st->aVal = n;
00074 }
00075 return (1);
00076 }
00077
00078
00079 int sqpFreeStmt(SQLPSTMT *st)
00080 {
00081 int i;
00082
00083
00084 for (i=0; i < st->aCol; i++)
00085 free ( st->Col[i].s );
00086
00087 free ( st->Col );
00088 free ( st->ColType );
00089 free ( st->ColWidth );
00090 free ( st->ColDecim );
00091 st->aCol = 0;
00092 st->nCol = 0;
00093
00094
00095 for (i=0; i < st->aVal; i++)
00096 free ( st->Val[i].s );
00097
00098 free ( st->Val );
00099 st->aVal = 0;
00100 st->nVal = 0;
00101
00102 free (st->orderCol);
00103
00104
00105 if ( st->upperNodeptr )
00106 sqpFreeNode ( st->upperNodeptr );
00107
00108 free ( st );
00109 return (1);
00110 }
00111
00112