filehash/ffdb_pagepool.c
int
ffdb_pagepool_create (ffdb_pagepool_t** pgp, unsigned int flags)
{
  int ret, i;

  ffdb_pagepool_t *p = (ffdb_pagepool_t *)malloc(sizeof(ffdb_pagepool_t));
  if (!p) {
    fprintf (stderr, "cannot allocate space for ffdb_pagepool_t structure.\n");
    return errno;
  }
  /**
   * initialize each element of this structure
   */
  memset (p, 0, sizeof(ffdb_pagepool_t));
  p->fd = -1;

  /**
   * Initialize LRU and hash table
   */
  FFDB_CIRCLEQ_INIT (&(p->lqh));
  for (i = 0; i < FFDB_HASHSIZE; i++) 
    FFDB_CIRCLEQ_INIT (&(p->hqh[i]));  

  /**
   * Create a pthread mutex lock
   */
  if ((ret = FFDB_LOCK_INIT (p->lock)) != 0) {
    free (p);
    return ret;
  }

  *pgp = p;
  return 0;
}
/**
 * Create ffdb_pagepool handle used by all threads of a process
 */
Create ffdb_pagepool handle used by all threads of a process
Create ffdb_pagepool handle used by all threads of a process
int
ffdb_pagepool_create (ffdb_pagepool_t** pgp, unsigned int flags)
{
  int ret, i;
  ffdb_pagepool_t *p = (ffdb_pagepool_t *)malloc(sizeof(ffdb_pagepool_t));
  if (!p) {
    fprintf (stderr, "cannot allocate space for ffdb_pagepool_t structure.\n");
    return errno;
  }
  memset (p, 0, sizeof(ffdb_pagepool_t));
  p->fd = -1;
  FFDB_CIRCLEQ_INIT (&(p->lqh));
  for (i = 0; i < FFDB_HASHSIZE; i++) 
    FFDB_CIRCLEQ_INIT (&(p->hqh[i]));  
  if ((ret = FFDB_LOCK_INIT (p->lock)) != 0) {
    free (p);
    return ret;
  }
  *pgp = p;
  return 0;
}
int ffdb_pagepool_create ( ffdb_pagepool_t * * pgp , unsigned int flags ) { int ret , i ; ffdb_pagepool_t * p = ( ffdb_pagepool_t * ) malloc ( sizeof ( ffdb_pagepool_t ) ) ; if ( ! p ) { fprintf ( stderr , " \n " ) ; return errno ; } memset ( p , 0 , sizeof ( ffdb_pagepool_t ) ) ; p -> fd = -1 ; FFDB_CIRCLEQ_INIT ( & ( p -> lqh ) ) ; for ( i = 0 ; i < FFDB_HASHSIZE ; i ++ ) FFDB_CIRCLEQ_INIT ( & ( p -> hqh [ i ] ) ) ; if ( ( ret = FFDB_LOCK_INIT ( p -> lock ) ) != 0 ) { free ( p ) ; return ret ; } * pgp = p ; return 0 ; }
Create ffdb_pagepool handle used by all threads of a process
Create ffdb_pagepool handle used by all threads of a process
/**
   * initialize each element of this structure
   */ /**
   * Initialize LRU and hash table
   */ /**
   * Create a pthread mutex lock
   */