/* ** Free all stems in a list. */ static void fuzzerClearStemList(ref fuzzer_stem pStem) { //while( pStem ){ // fuzzer_stem pNext = pStem.pNext; // sqlite3_free(pStem); // pStem = pNext; //} pStem = null; }
/* ** Compute the current output term for a fuzzer_stem. */ static int fuzzerRender( fuzzer_stem pStem, /* The stem to be rendered */ ref string pzBuf, /* Write results into this buffer. realloc if needed */ ref int pnBuf /* Size of the buffer */ ) { fuzzer_rule pRule = pStem.pRule; int n; string z; n = pStem.nBasis + pRule.nTo - pRule.nFrom; if ((pnBuf) < n + 1) { //(*pzBuf) = sqlite3_realloc((*pzBuf), n+100); //if( (*pzBuf)==0 ) return SQLITE_NOMEM; (pnBuf) = n + 100; } n = pStem.n; //z = pzBuf; if (n < 0) { z = pStem.zBasis.Substring(0, pStem.nBasis + 1);//memcpy(z, pStem.zBasis, pStem.nBasis+1); } else { z = pStem.zBasis.Substring(0, n);//memcpy( z, pStem.zBasis, n ); if (pRule.nTo != 0) { z += pRule.zTo.Substring(0, pRule.nTo);//memcpy(&z[n], pRule.zTo, pRule.nTo); } z += pStem.zBasis.Substring(n + pRule.nFrom, pStem.nBasis - n - pRule.nFrom); //memcpy(&z[n+pRule.nTo], &pStem.zBasis[n+pRule.nFrom], pStem.nBasis-n-pRule.nFrom+1); } pzBuf = z; return(SQLITE_OK); }
/* ** Current cost of a stem */ static fuzzer_cost fuzzerCost( fuzzer_stem pStem ) { return pStem.rCostX = pStem.rBaseCost + pStem.pRule.rCost; }
/* ** Compute the current output term for a fuzzer_stem. */ static int fuzzerRender( fuzzer_stem pStem, /* The stem to be rendered */ ref string pzBuf, /* Write results into this buffer. realloc if needed */ ref int pnBuf /* Size of the buffer */ ) { fuzzer_rule pRule = pStem.pRule; int n; string z; n = pStem.nBasis + pRule.nTo - pRule.nFrom; if ( ( pnBuf ) < n + 1 ) { //(*pzBuf) = sqlite3_realloc((*pzBuf), n+100); //if( (*pzBuf)==0 ) return SQLITE_NOMEM; ( pnBuf ) = n + 100; } n = pStem.n; //z = pzBuf; if ( n < 0 ) { z = pStem.zBasis.Substring( 0, pStem.nBasis + 1 );//memcpy(z, pStem.zBasis, pStem.nBasis+1); } else { z = pStem.zBasis.Substring( 0, n );//memcpy( z, pStem.zBasis, n ); if ( pRule.nTo != 0 ) z += pRule.zTo.Substring( 0, pRule.nTo );//memcpy(&z[n], pRule.zTo, pRule.nTo); z += pStem.zBasis.Substring( n + pRule.nFrom, pStem.nBasis - n - pRule.nFrom ); //memcpy(&z[n+pRule.nTo], &pStem.zBasis[n+pRule.nFrom], pStem.nBasis-n-pRule.nFrom+1); } pzBuf = z; return SQLITE_OK; }
/* ** Free all stems in a list. */ static void fuzzerClearStemList( ref fuzzer_stem pStem ) { //while( pStem ){ // fuzzer_stem pNext = pStem.pNext; // sqlite3_free(pStem); // pStem = pNext; //} pStem = null; }
/* ** Current cost of a stem */ static fuzzer_cost fuzzerCost(fuzzer_stem pStem) { return(pStem.rCostX = pStem.rBaseCost + pStem.pRule.rCost); }