Back to index

lightning-sunbird  0.9+nobinonly
Functions
vdbefifo.c File Reference
#include "sqliteInt.h"
#include "vdbeInt.h"

Go to the source code of this file.

Functions

static FifoPageallocatePage (int nEntry)
void sqlite3VdbeFifoInit (Fifo *pFifo)
int sqlite3VdbeFifoPush (Fifo *pFifo, i64 val)
int sqlite3VdbeFifoPop (Fifo *pFifo, i64 *pVal)
void sqlite3VdbeFifoClear (Fifo *pFifo)

Function Documentation

static FifoPage* allocatePage ( int  nEntry) [static]

Definition at line 22 of file vdbefifo.c.

                                         {
  FifoPage *pPage;
  if( nEntry>32767 ){
    nEntry = 32767;
  }
  pPage = sqliteMallocRaw( sizeof(FifoPage) + sizeof(i64)*(nEntry-1) );
  if( pPage ){
    pPage->nSlot = nEntry;
    pPage->iWrite = 0;
    pPage->iRead = 0;
    pPage->pNext = 0;
  }
  return pPage;
}

Here is the caller graph for this function:

Definition at line 107 of file vdbefifo.c.

                                      {
  FifoPage *pPage, *pNextPage;
  for(pPage=pFifo->pFirst; pPage; pPage=pNextPage){
    pNextPage = pPage->pNext;
    sqliteFree(pPage);
  }
  sqlite3VdbeFifoInit(pFifo);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 40 of file vdbefifo.c.

                                     {
  memset(pFifo, 0, sizeof(*pFifo));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqlite3VdbeFifoPop ( Fifo pFifo,
i64 pVal 
)

Definition at line 74 of file vdbefifo.c.

                                              {
  FifoPage *pPage;
  if( pFifo->nEntry==0 ){
    return SQLITE_DONE;
  }
  assert( pFifo->nEntry>0 );
  pPage = pFifo->pFirst;
  assert( pPage!=0 );
  assert( pPage->iWrite>pPage->iRead );
  assert( pPage->iWrite<=pPage->nSlot );
  assert( pPage->iRead<pPage->nSlot );
  assert( pPage->iRead>=0 );
  *pVal = pPage->aSlot[pPage->iRead++];
  pFifo->nEntry--;
  if( pPage->iRead>=pPage->iWrite ){
    pFifo->pFirst = pPage->pNext;
    sqliteFree(pPage);
    if( pFifo->nEntry==0 ){
      assert( pFifo->pLast==pPage );
      pFifo->pLast = 0;
    }else{
      assert( pFifo->pFirst!=0 );
    }
  }else{
    assert( pFifo->nEntry>0 );
  }
  return SQLITE_OK;
}

Here is the caller graph for this function:

int sqlite3VdbeFifoPush ( Fifo pFifo,
i64  val 
)

Definition at line 49 of file vdbefifo.c.

                                             {
  FifoPage *pPage;
  pPage = pFifo->pLast;
  if( pPage==0 ){
    pPage = pFifo->pLast = pFifo->pFirst = allocatePage(20);
    if( pPage==0 ){
      return SQLITE_NOMEM;
    }
  }else if( pPage->iWrite>=pPage->nSlot ){
    pPage->pNext = allocatePage(pFifo->nEntry);
    if( pPage->pNext==0 ){
      return SQLITE_NOMEM;
    }
    pPage = pFifo->pLast = pPage->pNext;
  }
  pPage->aSlot[pPage->iWrite++] = val;
  pFifo->nEntry++;
  return SQLITE_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function: