Пример #1
0
 /*
 ** Free up all the memory allocated by a cursor.  Set it rLimit to 0
 ** to indicate that it is at EOF.
 */
 static void fuzzerClearCursor( fuzzer_cursor pCur, int clearHash )
 {
   int i;
   fuzzerClearStemList( ref pCur.pStem );
   fuzzerClearStemList( ref pCur.pDone );
   for ( i = 0; i < FUZZER_NQUEUE; i++ )
     fuzzerClearStemList( ref pCur.aQueue[i] );
   pCur.rLimit = (fuzzer_cost)0;
   if ( clearHash != 0 && pCur.nStem != 0 )
   {
     pCur.mxQueue = 0;
     pCur.pStem = null;
     pCur.pDone = null;
     Array.Clear( pCur.aQueue, 0, pCur.aQueue.Length );//memset(pCur.aQueue, 0, sizeof(pCur.aQueue));
     Array.Clear( pCur.apHash, 0, pCur.apHash.Length );//memset(pCur.apHash, 0, sizeof(pCur.apHash));
   }
   pCur.nStem = 0;
 }
Пример #2
0
 /*
 ** Open a new fuzzer cursor.
 */
 static int fuzzerOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor )
 {
   fuzzer_vtab p = (fuzzer_vtab)pVTab;
   fuzzer_cursor pCur;
   pCur = new fuzzer_cursor();//= sqlite3_malloc( sizeof(pCur) );
   ///if( pCur==0 ) return SQLITE_NOMEM;
   //memset(pCur, 0, sizeof(pCur));
   pCur.pVtab = p;
   ppCursor = pCur;
   if ( p.nCursor == 0 && p.pNewRule != null )
   {
     uint i;
     fuzzer_rule pX;
     fuzzer_rule[] a = new fuzzer_rule[15];
     //for(i=0; i<sizeof(a)/sizeof(a[0]); i++) a[i] = 0;
     while ( ( pX = p.pNewRule ) != null )
     {
       p.pNewRule = pX.pNext;
       pX.pNext = null;
       for ( i = 0; a[i] != null && i < a.Length; i++ )//<sizeof(a)/sizeof(a[0])-1; i++)
       {
         pX = fuzzerMergeRules( a[i], pX );
         a[i] = null;
       }
       a[i] = fuzzerMergeRules( a[i], pX );
     }
     for ( pX = a[0], i = 1; i < a.Length; i++ )//sizeof(a)/sizeof(a[0]); i++)
     {
       pX = fuzzerMergeRules( a[i], pX );
     }
     p.pRule = fuzzerMergeRules( p.pRule, pX );
   }
   p.nCursor++;
   return SQLITE_OK;
 }