예제 #1
0
파일: ring.c 프로젝트: shengxinking/yaf
/**
 * rgaAlloc
 *
 *
 *
 */
rgaRing_t *rgaAlloc(
    size_t          elt_sz,
    size_t          cap)
{
    rgaRing_t        *ring = NULL;
    size_t            alignedEltSize = elt_sz;

#   if HAVE_ALIGNED_ACCESS_REQUIRED
    alignedEltSize += (elt_sz % (sizeof(uint64_t)));
#   endif
    /* allocate the structure */
    ring = yg_slice_new0(rgaRing_t);

    /* allocate the buffer */
    ring->base = yg_slice_alloc0(alignedEltSize * cap);

    /* note last element in array */
    ring->end = ring->base + (alignedEltSize * (cap - 1));

    /* set head and tail pointers to start of ring */
    ring->head = ring->tail = ring->base;

    /* stash element size and capacity */
    ring->elt_sz = alignedEltSize;
    ring->cap = cap;

    /* All done. */
    return ring;
}
예제 #2
0
/**
 * flowAlloc
 *
 * Allocate the hooks struct here, but don't allocate the DPI struct
 * until we want to fill it so we don't have to hold empty memory for long.
 *
 *
 */
void ypFlowAlloc(
    void ** yfHookContext,
    yfFlow_t *flow)
{
    ypDHCPFlowCtx_t   *flowContext = NULL;

    flowContext = (ypDHCPFlowCtx_t *) yg_slice_alloc0(sizeof(ypDHCPFlowCtx_t));

    *yfHookContext = (void *)flowContext;

    return;
}