]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In the kvtest.c test utility, reuse the buffer into which blobs are read,
authordrh <drh@noemail.net>
Sat, 21 Jan 2017 15:55:41 +0000 (15:55 +0000)
committerdrh <drh@noemail.net>
Sat, 21 Jan 2017 15:55:41 +0000 (15:55 +0000)
rather than reallocating it for each row.  This is a closer match to how
other test programs work, and thus provides a better comparison.

FossilOrigin-Name: 0d1ad13a296b22d6fe36879b56f99bd6af1acd3a

manifest
manifest.uuid
test/kvtest.c

index f0f41d4642f6dbc95d491e664b6a0dde04a4f200..17270cb28569a2bd3fec0c1b44b7e07a79a9f847 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\san\sunnecessary\ssqlite3_bind_int64()\scall\sfrom\ssqlite3_blob_open().\nAlso\sother\sminor\srefactoring\sof\sthe\ssqlite3_blob\simplementation.
-D 2017-01-21T14:11:28.343
+C In\sthe\skvtest.c\stest\sutility,\sreuse\sthe\sbuffer\sinto\swhich\sblobs\sare\sread,\nrather\sthan\sreallocating\sit\sfor\seach\srow.\s\sThis\sis\sa\scloser\smatch\sto\show\nother\stest\sprograms\swork,\sand\sthus\sprovides\sa\sbetter\scomparison.
+D 2017-01-21T15:55:41.656
 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -898,7 +898,7 @@ F test/json101.test c0897616f32d95431f37fd291cb78742181980ac
 F test/json102.test bf3fe7a706d30936a76a0f7a0375e1e8e73aff5a
 F test/json103.test c5f6b85e69de05f6b3195f9f9d5ce9cd179099a0
 F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
-F test/kvtest.c 371a2a0cb05840ed4a31c65c1d12a554c2fe556b
+F test/kvtest.c 9e428931f0733b5ba65b6b5abd95b27320e875a3
 F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
 F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
 F test/like.test 0603f4fa0dad50987f70032c05800cbfa8985302
@@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 264e5c10d7144910b3223b64546567fa20e4bc65
-R 8ac11845f3680b4a63ed584c4ec0c997
+P 9d197a532349f4b1caf66bbed70ca46df86cb86f
+R 2ba22a751baba0a74113cf71f6292807
 U drh
-Z e8ceb26091bad5772496cc1502eaca7e
+Z 28f64e9f53e7fb024862aee0e897381f
index ca6ba2e6ad990b52fcd11c1c8ca8e02e5718bdd6..1b9ab055af3b24cb75ae4f55b847e55ba9872c90 100644 (file)
@@ -1 +1 @@
-9d197a532349f4b1caf66bbed70ca46df86cb86f
\ No newline at end of file
+0d1ad13a296b22d6fe36879b56f99bd6af1acd3a
\ No newline at end of file
index 2e997287e8849ce4a177302045a50fcb862c8506..d895af030fb2cf1927df0d5e384af12b553b134a 100644 (file)
@@ -516,6 +516,7 @@ static int runMain(int argc, char **argv){
   int nData = 0;              /* Bytes of data */
   sqlite3_int64 nTotal = 0;   /* Total data read */
   unsigned char *pData;       /* Content of the blob */
+  int nAlloc = 0;             /* Space allocated for pData[] */
   
 
   assert( strcmp(argv[1],"run")==0 );
@@ -621,14 +622,16 @@ static int runMain(int argc, char **argv){
       }
       if( rc==SQLITE_OK ){
         nData = sqlite3_blob_bytes(pBlob);
-        pData = sqlite3_malloc( nData+1 );
+        if( nAlloc<nData+1 ){
+          nAlloc = nData+100;
+          pData = sqlite3_realloc(pData, nAlloc);
+        }
         if( pData==0 ) fatalError("cannot allocate %d bytes", nData+1);
         rc = sqlite3_blob_read(pBlob, pData, nData, 0);
         if( rc!=SQLITE_OK ){
           fatalError("could not read the blob at %d: %s", iKey,
                      sqlite3_errmsg(db));
         }
-        sqlite3_free(pData);
       }
     }else{
       /* CASE 3: Reading from database using SQL */
@@ -662,6 +665,7 @@ static int runMain(int argc, char **argv){
     nTotal += nData;
     if( nData==0 ){ nCount++; nExtra++; }
   }
+  if( nAlloc ) sqlite3_free(pData);
   if( pStmt ) sqlite3_finalize(pStmt);
   if( pBlob ) sqlite3_blob_close(pBlob);
   if( bStats ){