/ Check-in [6a94d197]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove all references to sqlite3_intptr_t. (CVS 5051)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6a94d19747a05df2694d3720f76de3dab3836578
User & Date: drh 2008-04-27 18:40:12
Context
2008-04-27
18:45
Fix the lemon parser generator so that it works again with the "error" symbol. Ticket #3079 (CVS 5052) check-in: 20ed7492 user: drh tags: trunk
18:40
Remove all references to sqlite3_intptr_t. (CVS 5051) check-in: 6a94d197 user: drh tags: trunk
2008-04-26
13:39
Use "(void)" function arguments in declarations instead of "()". Both are legal but some pedantic compilers complain about the latter. Ticket #3086. (CVS 5050) check-in: a4149ca3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.481 2008/04/17 20:59:38 drh Exp $
           25  +** $Id: build.c,v 1.482 2008/04/27 18:40:12 drh Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   #include <ctype.h>
    29     29   
    30     30   /*
    31     31   ** This routine is called when a new SQL statement is beginning to
    32     32   ** be parsed.  Initialize the pParse structure as needed.
................................................................................
  2289   2289     if( pIndex->onError!=OE_None ){
  2290   2290       int j1, j2;
  2291   2291       int regRowid;
  2292   2292   
  2293   2293       regRowid = regIdxKey + pIndex->nColumn;
  2294   2294       j1 = sqlite3VdbeAddOp3(v, OP_IsNull, regIdxKey, 0, pIndex->nColumn);
  2295   2295       j2 = sqlite3VdbeAddOp4(v, OP_IsUnique, iIdx,
  2296         -                           0, regRowid, (char*)(sqlite3_intptr_t)regRecord, P4_INT32);
         2296  +                           0, regRowid, (char*)regRecord, P4_INT32);
  2297   2297       sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort, 0,
  2298   2298                       "indexed columns are not unique", P4_STATIC);
  2299   2299       sqlite3VdbeJumpHere(v, j1);
  2300   2300       sqlite3VdbeJumpHere(v, j2);
  2301   2301     }
  2302   2302     sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);
  2303   2303     sqlite3ReleaseTempReg(pParse, regRecord);

Changes to src/func.c.

    12     12   ** This file contains the C functions that implement various SQL
    13     13   ** functions of SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: func.c,v 1.191 2008/03/20 16:30:18 drh Exp $
           19  +** $Id: func.c,v 1.192 2008/04/27 18:40:12 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   #include <assert.h>
    25     25   #include "vdbeInt.h"
    26     26   
................................................................................
   863    863     sqlite3_context *context,
   864    864     int argc,
   865    865     sqlite3_value **argv
   866    866   ){
   867    867     const unsigned char *zIn;         /* Input string */
   868    868     const unsigned char *zCharSet;    /* Set of characters to trim */
   869    869     int nIn;                          /* Number of bytes in input */
   870         -  sqlite3_intptr_t flags;           /* 1: trimleft  2: trimright  3: trim */
          870  +  int flags;                        /* 1: trimleft  2: trimright  3: trim */
   871    871     int i;                            /* Loop counter */
   872    872     unsigned char *aLen;              /* Length of each character in zCharSet */
   873    873     unsigned char **azChar;           /* Individual characters in zCharSet */
   874    874     int nChar;                        /* Number of characters in zCharSet */
   875    875   
   876    876     if( sqlite3_value_type(argv[0])==SQLITE_NULL ){
   877    877       return;
................................................................................
   904    904           azChar[nChar] = (unsigned char *)z;
   905    905           SQLITE_SKIP_UTF8(z);
   906    906           aLen[nChar] = z - azChar[nChar];
   907    907         }
   908    908       }
   909    909     }
   910    910     if( nChar>0 ){
   911         -    flags = (sqlite3_intptr_t)sqlite3_user_data(context);
          911  +    flags = (int)sqlite3_user_data(context);
   912    912       if( flags & 1 ){
   913    913         while( nIn>0 ){
   914    914           int len;
   915    915           for(i=0; i<nChar; i++){
   916    916             len = aLen[i];
   917    917             if( memcmp(zIn, azChar[i], len)==0 ) break;
   918    918           }
................................................................................
  1279   1279       { "group_concat", 2, 0, 0, groupConcatStep, groupConcatFinalize },
  1280   1280     };
  1281   1281     int i;
  1282   1282   
  1283   1283     for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
  1284   1284       void *pArg;
  1285   1285       u8 argType = aFuncs[i].argType;
  1286         -    pArg = (void*)(sqlite3_intptr_t)argType;
         1286  +    pArg = (void*)(int)argType;
  1287   1287       sqlite3CreateFunc(db, aFuncs[i].zName, aFuncs[i].nArg,
  1288   1288           aFuncs[i].eTextRep, pArg, aFuncs[i].xFunc, 0, 0);
  1289   1289       if( aFuncs[i].needCollSeq ){
  1290   1290         FuncDef *pFunc = sqlite3FindFunction(db, aFuncs[i].zName, 
  1291   1291             strlen(aFuncs[i].zName), aFuncs[i].nArg, aFuncs[i].eTextRep, 0);
  1292   1292         if( pFunc && aFuncs[i].needCollSeq ){
  1293   1293           pFunc->needCollSeq = 1;
................................................................................
  1297   1297   #ifndef SQLITE_OMIT_ALTERTABLE
  1298   1298     sqlite3AlterFunctions(db);
  1299   1299   #endif
  1300   1300   #ifndef SQLITE_OMIT_PARSER
  1301   1301     sqlite3AttachFunctions(db);
  1302   1302   #endif
  1303   1303     for(i=0; i<sizeof(aAggs)/sizeof(aAggs[0]); i++){
  1304         -    void *pArg = (void*)(sqlite3_intptr_t)aAggs[i].argType;
         1304  +    void *pArg = (void*)(int)aAggs[i].argType;
  1305   1305       sqlite3CreateFunc(db, aAggs[i].zName, aAggs[i].nArg, SQLITE_UTF8, 
  1306   1306           pArg, 0, aAggs[i].xStep, aAggs[i].xFinalize);
  1307   1307       if( aAggs[i].needCollSeq ){
  1308   1308         FuncDef *pFunc = sqlite3FindFunction( db, aAggs[i].zName,
  1309   1309             strlen(aAggs[i].zName), aAggs[i].nArg, SQLITE_UTF8, 0);
  1310   1310         if( pFunc && aAggs[i].needCollSeq ){
  1311   1311           pFunc->needCollSeq = 1;

Changes to src/insert.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains C code routines that are called by the parser
    13     13   ** to handle INSERT statements in SQLite.
    14     14   **
    15         -** $Id: insert.c,v 1.236 2008/04/11 15:36:03 drh Exp $
           15  +** $Id: insert.c,v 1.237 2008/04/27 18:40:12 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   /*
    20     20   ** Set P4 of the most recently inserted opcode to a column affinity
    21     21   ** string for index pIdx. A column affinity string has one character
    22     22   ** for each column in the table, according to the affinity of the column:
................................................................................
  1189   1189       
  1190   1190   
  1191   1191       /* Check to see if the new index entry will be unique */
  1192   1192       j2 = sqlite3VdbeAddOp3(v, OP_IsNull, regIdx, 0, pIdx->nColumn);
  1193   1193       regR = sqlite3GetTempReg(pParse);
  1194   1194       sqlite3VdbeAddOp2(v, OP_SCopy, regRowid-hasTwoRowids, regR);
  1195   1195       j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur+iCur+1, 0,
  1196         -                           regR, (char*)(sqlite3_intptr_t)aRegIdx[iCur],
         1196  +                           regR, (char*)aRegIdx[iCur],
  1197   1197                              P4_INT32);
  1198   1198   
  1199   1199       /* Generate code that executes if the new index entry is not unique */
  1200   1200       assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
  1201   1201           || onError==OE_Ignore || onError==OE_Replace );
  1202   1202       switch( onError ){
  1203   1203         case OE_Rollback:

Changes to src/sqliteInt.h.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.695 2008/04/24 19:15:10 shane Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.696 2008/04/27 18:40:12 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Include the configuration header output by 'configure' if it was run
    21     21   ** (otherwise we get an empty default).
................................................................................
    31     31   #pragma warn -csu /* Comparing signed and unsigned */
    32     32   #pragma warn -spa /* Suspicous pointer arithmetic */
    33     33   #endif
    34     34   
    35     35   /* Needed for various definitions... */
    36     36   #define _GNU_SOURCE
    37     37   
    38         -/*
    39         -** Include standard header files as necessary
    40         -*/
    41         -#ifdef HAVE_STDINT_H
    42         -#include <stdint.h>
    43         -#endif
    44         -#ifdef HAVE_INTTYPES_H
    45         -#include <inttypes.h>
    46         -#endif
    47         -
    48         -/*
    49         -** If possible, use the C99 intptr_t type to define an integral type of
    50         -** equivalent size to a pointer.  (Technically it's >= sizeof(void *), but
    51         -** practically it's == sizeof(void *)).  We fall back to an int if this type
    52         -** isn't defined.
    53         -*/
    54         -#ifdef HAVE_INTPTR_T
    55         -  typedef intptr_t sqlite3_intptr_t;
    56         -#else
    57         -  typedef int sqlite3_intptr_t;
    58         -#endif
    59         -
    60     38   /*
    61     39   ** A macro used to aid in coverage testing.  When doing coverage
    62     40   ** testing, the condition inside the argument must be evaluated 
    63     41   ** both true and false in order to get full branch coverage.
    64     42   ** This macro can be inserted to ensure adequate test coverage
    65     43   ** in places where simple condition/decision coverage is inadequate.
    66     44   */

Changes to src/table.c.

   141    141     if( res.azResult==0 ){
   142    142        db->errCode = SQLITE_NOMEM;
   143    143        return SQLITE_NOMEM;
   144    144     }
   145    145     res.azResult[0] = 0;
   146    146     rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
   147    147     assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
   148         -  res.azResult[0] = (char*)(sqlite3_intptr_t)res.nData;
          148  +  res.azResult[0] = (char*)res.nData;
   149    149     if( (rc&0xff)==SQLITE_ABORT ){
   150    150       sqlite3_free_table(&res.azResult[1]);
   151    151       if( res.zErrMsg ){
   152    152         if( pzErrMsg ){
   153    153           sqlite3_free(*pzErrMsg);
   154    154           *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
   155    155         }
................................................................................
   183    183   /*
   184    184   ** This routine frees the space the sqlite3_get_table() malloced.
   185    185   */
   186    186   void sqlite3_free_table(
   187    187     char **azResult            /* Result returned from from sqlite3_get_table() */
   188    188   ){
   189    189     if( azResult ){
   190         -    sqlite3_intptr_t i, n;
          190  +    int i, n;
   191    191       azResult--;
   192    192       assert( azResult!=0 );
   193         -    n = (sqlite3_intptr_t)azResult[0];
          193  +    n = (int)azResult[0];
   194    194       for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }
   195    195       sqlite3_free(azResult);
   196    196     }
   197    197   }
   198    198   
   199    199   #endif /* SQLITE_OMIT_GET_TABLE */

Changes to src/vdbeaux.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used for creating, destroying, and populating
    13     13   ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.)  Prior
    14     14   ** to version 2.8.7, all this code was combined into the vdbe.c source file.
    15     15   ** But that file was getting too big so this subroutines were split out.
    16     16   **
    17         -** $Id: vdbeaux.c,v 1.379 2008/04/24 19:15:11 shane Exp $
           17  +** $Id: vdbeaux.c,v 1.380 2008/04/27 18:40:12 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include <ctype.h>
    21     21   #include "vdbeInt.h"
    22     22   
    23     23   
    24     24   
................................................................................
   532    532     }
   533    533     pOp = &p->aOp[addr];
   534    534     freeP4(pOp->p4type, pOp->p4.p);
   535    535     pOp->p4.p = 0;
   536    536     if( n==P4_INT32 ){
   537    537       /* Note: this cast is safe, because the origin data point was an int
   538    538       ** that was cast to a (const char *). */
   539         -    pOp->p4.i = (int)(sqlite3_intptr_t)zP4;
          539  +    pOp->p4.i = (int)zP4;
   540    540       pOp->p4type = n;
   541    541     }else if( zP4==0 ){
   542    542       pOp->p4.p = 0;
   543    543       pOp->p4type = P4_NOTUSED;
   544    544     }else if( n==P4_KEYINFO ){
   545    545       KeyInfo *pKeyInfo;
   546    546       int nField, nByte;

Changes to src/vdbemem.c.

   889    889       return 0;
   890    890     }
   891    891     assert( (MEM_Blob>>3) == MEM_Str );
   892    892     pVal->flags |= (pVal->flags & MEM_Blob)>>3;
   893    893     expandBlob(pVal);
   894    894     if( pVal->flags&MEM_Str ){
   895    895       sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED);
   896         -    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(sqlite3_intptr_t)pVal->z) ){
          896  +    if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(int)pVal->z) ){
   897    897         assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 );
   898    898         if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){
   899    899           return 0;
   900    900         }
   901    901       }
   902    902       sqlite3VdbeMemNulTerminate(pVal);
   903    903     }else{
   904    904       assert( (pVal->flags&MEM_Blob)==0 );
   905    905       sqlite3VdbeMemStringify(pVal, enc);
   906         -    assert( 0==(1&(sqlite3_intptr_t)pVal->z) );
          906  +    assert( 0==(1&(int)pVal->z) );
   907    907     }
   908    908     assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || pVal->db==0
   909    909                 || pVal->db->mallocFailed );
   910    910     if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){
   911    911       return pVal->z;
   912    912     }else{
   913    913       return 0;

Changes to src/vtab.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to help implement virtual tables.
    13     13   **
    14         -** $Id: vtab.c,v 1.66 2008/04/10 18:35:22 drh Exp $
           14  +** $Id: vtab.c,v 1.67 2008/04/27 18:40:12 drh Exp $
    15     15   */
    16     16   #ifndef SQLITE_OMIT_VIRTUALTABLE
    17     17   #include "sqliteInt.h"
    18     18   
    19     19   static int createModule(
    20     20     sqlite3 *db,                    /* Database in which module is registered */
    21     21     const char *zName,              /* Name assigned to this module */
................................................................................
   614    614   ** This function invokes either the xRollback or xCommit method
   615    615   ** of each of the virtual tables in the sqlite3.aVTrans array. The method
   616    616   ** called is identified by the second argument, "offset", which is
   617    617   ** the offset of the method to call in the sqlite3_module structure.
   618    618   **
   619    619   ** The array is cleared after invoking the callbacks. 
   620    620   */
   621         -static void callFinaliser(sqlite3 *db, sqlite3_intptr_t offset){
          621  +static void callFinaliser(sqlite3 *db, int offset){
   622    622     int i;
   623    623     if( db->aVTrans ){
   624    624       for(i=0; i<db->nVTrans && db->aVTrans[i]; i++){
   625    625         sqlite3_vtab *pVtab = db->aVTrans[i];
   626    626         int (*x)(sqlite3_vtab *);
   627    627         x = *(int (**)(sqlite3_vtab *))((char *)pVtab->pModule + offset);
   628    628         if( x ) x(pVtab);
................................................................................
   667    667   }
   668    668   
   669    669   /*
   670    670   ** Invoke the xRollback method of all virtual tables in the 
   671    671   ** sqlite3.aVTrans array. Then clear the array itself.
   672    672   */
   673    673   int sqlite3VtabRollback(sqlite3 *db){
   674         -  callFinaliser(db, (sqlite3_intptr_t)(&((sqlite3_module *)0)->xRollback));
          674  +  callFinaliser(db, offsetof(sqlite3_module,xRollback));
   675    675     return SQLITE_OK;
   676    676   }
   677    677   
   678    678   /*
   679    679   ** Invoke the xCommit method of all virtual tables in the 
   680    680   ** sqlite3.aVTrans array. Then clear the array itself.
   681    681   */
   682    682   int sqlite3VtabCommit(sqlite3 *db){
   683         -  callFinaliser(db, (sqlite3_intptr_t)(&((sqlite3_module *)0)->xCommit));
          683  +  callFinaliser(db, offsetof(sqlite3_module,xCommit));
   684    684     return SQLITE_OK;
   685    685   }
   686    686   
   687    687   /*
   688    688   ** If the virtual table pVtab supports the transaction interface
   689    689   ** (xBegin/xRollback/xCommit and optionally xSync) and a transaction is
   690    690   ** not currently open, invoke the xBegin method now.