aboutsummaryrefslogtreecommitdiff
path: root/src/test_hexio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test_hexio.c')
-rw-r--r--src/test_hexio.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/test_hexio.c b/src/test_hexio.c
index 61a41d5b1..3c856b330 100644
--- a/src/test_hexio.c
+++ b/src/test_hexio.c
@@ -18,11 +18,7 @@
** easier and safer to build our own mechanism.
*/
#include "sqliteInt.h"
-#if defined(INCLUDE_SQLITE_TCL_H)
-# include "sqlite_tcl.h"
-#else
-# include "tcl.h"
-#endif
+#include "tclsqlite.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
@@ -155,7 +151,8 @@ static int SQLITE_TCLAPI hexio_write(
Tcl_Obj *CONST objv[]
){
int offset;
- int nIn, nOut, written;
+ Tcl_Size nIn;
+ int nOut, written;
const char *zFile;
const unsigned char *zIn;
unsigned char *aOut;
@@ -168,11 +165,11 @@ static int SQLITE_TCLAPI hexio_write(
if( Tcl_GetIntFromObj(interp, objv[2], &offset) ) return TCL_ERROR;
zFile = Tcl_GetString(objv[1]);
zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[3], &nIn);
- aOut = sqlite3_malloc( 1 + nIn/2 );
+ aOut = sqlite3_malloc64( 1 + nIn/2 );
if( aOut==0 ){
return TCL_ERROR;
}
- nOut = sqlite3TestHexToBin(zIn, nIn, aOut);
+ nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut);
out = fopen(zFile, "r+b");
if( out==0 ){
out = fopen(zFile, "r+");
@@ -203,7 +200,8 @@ static int SQLITE_TCLAPI hexio_get_int(
Tcl_Obj *CONST objv[]
){
int val;
- int nIn, nOut;
+ Tcl_Size nIn;
+ int nOut;
const unsigned char *zIn;
unsigned char *aOut;
unsigned char aNum[4];
@@ -213,11 +211,11 @@ static int SQLITE_TCLAPI hexio_get_int(
return TCL_ERROR;
}
zIn = (const unsigned char *)Tcl_GetStringFromObj(objv[1], &nIn);
- aOut = sqlite3_malloc( 1 + nIn/2 );
+ aOut = sqlite3_malloc64( 1 + nIn/2 );
if( aOut==0 ){
return TCL_ERROR;
}
- nOut = sqlite3TestHexToBin(zIn, nIn, aOut);
+ nOut = sqlite3TestHexToBin(zIn, (int)nIn, aOut);
if( nOut>=4 ){
memcpy(aNum, aOut, 4);
}else{
@@ -300,7 +298,7 @@ static int SQLITE_TCLAPI utf8_to_utf8(
Tcl_Obj *CONST objv[]
){
#ifdef SQLITE_DEBUG
- int n;
+ Tcl_Size n;
int nOut;
const unsigned char *zOrig;
unsigned char *z;
@@ -309,8 +307,8 @@ static int SQLITE_TCLAPI utf8_to_utf8(
return TCL_ERROR;
}
zOrig = (unsigned char *)Tcl_GetStringFromObj(objv[1], &n);
- z = sqlite3_malloc( n+4 );
- n = sqlite3TestHexToBin(zOrig, n, z);
+ z = sqlite3_malloc64( n+4 );
+ n = sqlite3TestHexToBin(zOrig, (int)n, z);
z[n] = 0;
nOut = sqlite3Utf8To8(z);
sqlite3TestBinToHex(z,nOut);
@@ -361,7 +359,7 @@ static int SQLITE_TCLAPI read_fts3varint(
int objc,
Tcl_Obj *CONST objv[]
){
- int nBlob;
+ Tcl_Size nBlob;
unsigned char *zBlob;
sqlite3_int64 iVal;
int nVal;
@@ -388,10 +386,10 @@ static int SQLITE_TCLAPI make_fts3record(
Tcl_Obj *CONST objv[]
){
Tcl_Obj **aArg = 0;
- int nArg = 0;
+ Tcl_Size nArg = 0;
unsigned char *aOut = 0;
- int nOut = 0;
- int nAlloc = 0;
+ sqlite3_int64 nOut = 0;
+ sqlite3_int64 nAlloc = 0;
int i;
if( objc!=2 ){
@@ -402,8 +400,8 @@ static int SQLITE_TCLAPI make_fts3record(
return TCL_ERROR;
}
- for(i=0; i<nArg; i++){
- sqlite3_int64 iVal;
+ for(i=0; i<(int)nArg; i++){
+ Tcl_WideInt iVal;
if( TCL_OK==Tcl_GetWideIntFromObj(0, aArg[i], &iVal) ){
if( nOut+10>nAlloc ){
int nNew = nAlloc?nAlloc*2:128;
@@ -417,11 +415,11 @@ static int SQLITE_TCLAPI make_fts3record(
}
nOut += putFts3Varint((char*)&aOut[nOut], iVal);
}else{
- int nVal = 0;
+ Tcl_Size nVal = 0;
char *zVal = Tcl_GetStringFromObj(aArg[i], &nVal);
while( (nOut + nVal)>nAlloc ){
- int nNew = nAlloc?nAlloc*2:128;
- unsigned char *aNew = sqlite3_realloc(aOut, nNew);
+ sqlite3_int64 nNew = nAlloc?nAlloc*2:128;
+ unsigned char *aNew = sqlite3_realloc64(aOut, nNew);
if( aNew==0 ){
sqlite3_free(aOut);
return TCL_ERROR;