OLD | NEW |
1 /* | 1 /* |
2 ** 2011 March 24 | 2 ** 2011 March 24 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 p->zClassName, FUZZER_MX_RULEID | 335 p->zClassName, FUZZER_MX_RULEID |
336 ); | 336 ); |
337 rc = SQLITE_ERROR; | 337 rc = SQLITE_ERROR; |
338 }else{ | 338 }else{ |
339 | 339 |
340 pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo ); | 340 pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo ); |
341 if( pRule==0 ){ | 341 if( pRule==0 ){ |
342 rc = SQLITE_NOMEM; | 342 rc = SQLITE_NOMEM; |
343 }else{ | 343 }else{ |
344 memset(pRule, 0, sizeof(*pRule)); | 344 memset(pRule, 0, sizeof(*pRule)); |
345 pRule->zFrom = &pRule->zTo[nTo+1]; | 345 pRule->zFrom = pRule->zTo; |
| 346 pRule->zFrom += nTo + 1; |
346 pRule->nFrom = nFrom; | 347 pRule->nFrom = nFrom; |
347 memcpy(pRule->zFrom, zFrom, nFrom+1); | 348 memcpy(pRule->zFrom, zFrom, nFrom+1); |
348 memcpy(pRule->zTo, zTo, nTo+1); | 349 memcpy(pRule->zTo, zTo, nTo+1); |
349 pRule->nTo = nTo; | 350 pRule->nTo = nTo; |
350 pRule->rCost = nCost; | 351 pRule->rCost = nCost; |
351 pRule->iRuleset = (int)iRuleset; | 352 pRule->iRuleset = (int)iRuleset; |
352 } | 353 } |
353 } | 354 } |
354 | 355 |
355 *ppRule = pRule; | 356 *ppRule = pRule; |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 fuzzer_cost rBaseCost | 869 fuzzer_cost rBaseCost |
869 ){ | 870 ){ |
870 fuzzer_stem *pNew; | 871 fuzzer_stem *pNew; |
871 fuzzer_rule *pRule; | 872 fuzzer_rule *pRule; |
872 unsigned int h; | 873 unsigned int h; |
873 | 874 |
874 pNew = sqlite3_malloc( sizeof(*pNew) + (int)strlen(zWord) + 1 ); | 875 pNew = sqlite3_malloc( sizeof(*pNew) + (int)strlen(zWord) + 1 ); |
875 if( pNew==0 ) return 0; | 876 if( pNew==0 ) return 0; |
876 memset(pNew, 0, sizeof(*pNew)); | 877 memset(pNew, 0, sizeof(*pNew)); |
877 pNew->zBasis = (char*)&pNew[1]; | 878 pNew->zBasis = (char*)&pNew[1]; |
878 pNew->nBasis = (int)strlen(zWord); | 879 pNew->nBasis = (fuzzer_len)strlen(zWord); |
879 memcpy(pNew->zBasis, zWord, pNew->nBasis+1); | 880 memcpy(pNew->zBasis, zWord, pNew->nBasis+1); |
880 pRule = pCur->pVtab->pRule; | 881 pRule = pCur->pVtab->pRule; |
881 while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){ | 882 while( fuzzerSkipRule(pRule, pNew, pCur->iRuleset) ){ |
882 pRule = pRule->pNext; | 883 pRule = pRule->pNext; |
883 } | 884 } |
884 pNew->pRule = pRule; | 885 pNew->pRule = pRule; |
885 pNew->n = -1; | 886 pNew->n = -1; |
886 pNew->rBaseCost = pNew->rCostX = rBaseCost; | 887 pNew->rBaseCost = pNew->rCostX = rBaseCost; |
887 h = fuzzerHash(pNew->zBasis); | 888 h = fuzzerHash(pNew->zBasis); |
888 pNew->pHash = pCur->apHash[h]; | 889 pNew->pHash = pCur->apHash[h]; |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 char **pzErrMsg, | 1176 char **pzErrMsg, |
1176 const sqlite3_api_routines *pApi | 1177 const sqlite3_api_routines *pApi |
1177 ){ | 1178 ){ |
1178 int rc = SQLITE_OK; | 1179 int rc = SQLITE_OK; |
1179 SQLITE_EXTENSION_INIT2(pApi); | 1180 SQLITE_EXTENSION_INIT2(pApi); |
1180 #ifndef SQLITE_OMIT_VIRTUALTABLE | 1181 #ifndef SQLITE_OMIT_VIRTUALTABLE |
1181 rc = sqlite3_create_module(db, "fuzzer", &fuzzerModule, 0); | 1182 rc = sqlite3_create_module(db, "fuzzer", &fuzzerModule, 0); |
1182 #endif | 1183 #endif |
1183 return rc; | 1184 return rc; |
1184 } | 1185 } |
OLD | NEW |