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