diff options
author | drh <drh@noemail.net> | 2004-06-19 15:22:56 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2004-06-19 15:22:56 +0000 |
commit | 998da3a287ef7ec59b52d7a1cc2246eb8e127fcb (patch) | |
tree | 4c64d240506b062ba20221b89325955d16cb21bd /src | |
parent | a99db3b6accf3b7c0fb4c0a6a3585e2f69161713 (diff) | |
download | sqlite-998da3a287ef7ec59b52d7a1cc2246eb8e127fcb.tar.gz sqlite-998da3a287ef7ec59b52d7a1cc2246eb8e127fcb.zip |
Fix problems with the WatCom C compiler: Arrays must contain at least one
element. sqlite3FreeX declared properly. Don't allow run-time expression
(the SQLITE_UTF16NATIVE macro) in an array initializer. (CVS 1640)
FossilOrigin-Name: fbfc3c95a8abf25bb9e2b44cfeb7186c5b0591d7
Diffstat (limited to 'src')
-rw-r--r-- | src/pragma.c | 19 | ||||
-rw-r--r-- | src/sqliteInt.h | 4 | ||||
-rw-r--r-- | src/vdbeInt.h | 20 | ||||
-rw-r--r-- | src/vdbeapi.c | 11 |
4 files changed, 33 insertions, 21 deletions
diff --git a/src/pragma.c b/src/pragma.c index 78fafbf12..482a82679 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.49 2004/06/19 14:49:12 drh Exp $ +** $Id: pragma.c,v 1.50 2004/06/19 15:22:56 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -767,17 +767,18 @@ void sqlite3Pragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){ char *zName; u8 enc; } encnames[] = { - { "UTF-8", SQLITE_UTF8 }, - { "UTF-16le", SQLITE_UTF16LE }, - { "UTF-16be", SQLITE_UTF16BE }, - { "UTF-16", SQLITE_UTF16NATIVE }, - { "UTF8", SQLITE_UTF8 }, - { "UTF16le", SQLITE_UTF16LE }, - { "UTF16be", SQLITE_UTF16BE }, - { "UTF16", SQLITE_UTF16NATIVE }, + { "UTF-8", SQLITE_UTF8 }, + { "UTF8", SQLITE_UTF8 }, + { "UTF-16le", SQLITE_UTF16LE }, + { "UTF16le", SQLITE_UTF16LE }, + { "UTF-16be", SQLITE_UTF16BE }, + { "UTF16be", SQLITE_UTF16BE }, + { "UTF-16", 0 /* Filled in at run-time */ }, + { "UTF16", 0 /* Filled in at run-time */ }, { 0, 0 } }; struct EncName *pEnc; + encnames[6].enc = encnames[7].enc = SQLITE_UTF16NATIVE; if( pRight->z==pLeft->z ){ /* "PRAGMA encoding" */ if( SQLITE_OK!=sqlite3ReadSchema(pParse->db, &pParse->zErrMsg) ){ pParse->nErr++; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 18d91d2db..5848b074d 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.293 2004/06/19 14:49:12 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.294 2004/06/19 15:22:56 drh Exp $ */ #include "config.h" #include "sqlite3.h" @@ -1221,7 +1221,6 @@ void sqlite3RealToSortable(double r, char *); char *sqlite3StrDup_(const char*,char*,int); char *sqlite3StrNDup_(const char*, int,char*,int); void sqlite3CheckMemory(void*,int); - void sqlite3FreeX(void *p); #else void *sqlite3Malloc(int); void *sqlite3MallocRaw(int); @@ -1231,6 +1230,7 @@ void sqlite3RealToSortable(double r, char *); char *sqlite3StrNDup(const char*, int); # define sqlite3CheckMemory(a,b) #endif +void sqlite3FreeX(void*); char *sqlite3MPrintf(const char*, ...); char *sqlite3VMPrintf(const char*, va_list); void sqlite3DebugPrintf(const char*, ...); diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 1e770e48c..bae5bba80 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -181,13 +181,23 @@ struct Sorter { */ #define MEM_AggCtx 0x0400 /* Mem.z points to an agg function context */ + +/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains +** additional information about auxiliary information bound to arguments +** of the function. This is used to implement the sqlite3_get_auxdata() +** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data +** that can be associated with a constant argument to a function. This +** allows functions such as "regexp" to compile their constant regular +** expression argument once and reused the compiled code for multiple +** invocations. +*/ struct VdbeFunc { - FuncDef *pFunc; - int nAux; + FuncDef *pFunc; /* The definition of the function */ + int nAux; /* Number of entries allocated for apAux[] */ struct AuxData { - void *pAux; - void (*xDelete)(void *); - } apAux[0]; + void *pAux; /* Aux data for the i-th argument */ + void (*xDelete)(void *); /* Destructor for the aux data */ + } apAux[1]; /* One slot for each function argument */ }; typedef struct VdbeFunc VdbeFunc; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7ca1e5997..6aee6b673 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -236,11 +236,12 @@ void sqlite3_set_auxdata( if( iArg<0 ) return; if( !pCtx->pVdbeFunc || pCtx->pVdbeFunc->nAux<=iArg ){ - int nMalloc = sizeof(VdbeFunc)+sizeof(struct AuxData)*(iArg+1); - pCtx->pVdbeFunc = sqliteRealloc(pCtx->pVdbeFunc, nMalloc); - if( !pCtx->pVdbeFunc ) return; - pCtx->pVdbeFunc->nAux = iArg+1; - pCtx->pVdbeFunc->pFunc = pCtx->pFunc; + VdbeFunc *pVdbeFunc; + int nMalloc = sizeof(VdbeFunc)+sizeof(struct AuxData)*iArg; + pCtx->pVdbeFunc = pVdbeFunc = sqliteRealloc(pCtx->pVdbeFunc, nMalloc); + if( !pVdbeFunc ) return; + pVdbeFunc->nAux = iArg+1; + pVdbeFunc->pFunc = pCtx->pFunc; } pAuxData = &pCtx->pVdbeFunc->apAux[iArg]; |