Changes to spellfix to try to get it to use stack space instead of heap space

in cases where that makes sense.

FossilOrigin-Name: dfcebc7393a3a780ee9c4f257723c303bb633064
This commit is contained in:
drh 2016-01-23 18:24:52 +00:00
parent c66d03f1e1
commit c6aab32144
3 changed files with 21 additions and 12 deletions

View File

@ -365,8 +365,8 @@ static int editdist1(const char *zA, const char *zB, int *pnMatch){
int *m; /* The cost matrix */
char *cx; /* Corresponding character values */
int *toFree = 0; /* Malloced space */
int mStack[60+15]; /* Stack space to use if not too much is needed */
int nMatch = 0;
int mStack[60+15]; /* Stack space to use if not too much is needed */
/* Early out if either input is NULL */
if( zA==0 || zB==0 ) return -1;
@ -899,15 +899,24 @@ static int editDist3Core(
EditDist3FromString f = *pFrom;
EditDist3To *a2;
unsigned int *m;
unsigned int *pToFree;
int szRow;
EditDist3Cost *p;
int res;
sqlite3_uint64 nByte;
unsigned int stackSpace[16*1024];
/* allocate the Wagner matrix and the aTo[] array for the TO string */
n = (f.n+1)*(n2+1);
n = (n+1)&~1;
m = sqlite3_malloc( n*sizeof(m[0]) + sizeof(a2[0])*n2 );
if( m==0 ) return -1; /* Out of memory */
nByte = n*sizeof(m[0]) + sizeof(a2[0])*n2;
if( nByte<=sizeof(stackSpace) ){
m = stackSpace;
pToFree = 0;
}else{
m = pToFree = sqlite3_malloc( nByte );
if( m==0 ) return -1; /* Out of memory */
}
a2 = (EditDist3To*)&m[n];
memset(a2, 0, sizeof(a2[0])*n2);
@ -1029,7 +1038,7 @@ static int editDist3Core(
editDist3Abort:
for(i2=0; i2<n2; i2++) sqlite3_free(a2[i2].apIns);
sqlite3_free(m);
sqlite3_free(pToFree);
return res;
}

View File

@ -1,5 +1,5 @@
C Fix\ssome\ssigned/unsigned\scomparison\scompiler\swarnings\sin\sfts5.
D 2016-01-23T15:57:06.186
C Changes\sto\sspellfix\sto\stry\sto\sget\sit\sto\suse\sstack\sspace\sinstead\sof\sheap\sspace\nin\scases\swhere\sthat\smakes\ssense.
D 2016-01-23T18:24:52.238
F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 1708a78eda223b6daa302b140037fcc214a779f9
@ -210,7 +210,7 @@ F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
F ext/misc/series.c b8fb7befd85b3a9b4a10e701b30b2b79ca92b6d4
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
F ext/misc/spellfix.c df6efb90eb668d1860c9b59e4320e985e46dffa7
F ext/misc/spellfix.c 5850a0e05ae1eacd48a3d80991c63b58d41e2d27
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e
@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P f0a551edf87ef061deae34d88b02c3b484ae9adc
R 962289f1674397e1ac71fafb409f527f
U dan
Z 5f630552e065d9e5a5f7f6919a0222d3
P 3be336aa893f9eb0837d7d66c83bab1489792b9a
R e0cc5654cf9d372268674d3acd0d1178
U drh
Z 5f4045218ee81aac454594c9cbaf4e94

View File

@ -1 +1 @@
3be336aa893f9eb0837d7d66c83bab1489792b9a
dfcebc7393a3a780ee9c4f257723c303bb633064