porting/dpl_lib/src/dpl_mem.c
/**
 * Mallocs a block of memory and initializes an mbuf pool to use it.  The
 * specified block_size indicates the size of an mbuf acquired from the pool if
 * it does not contain a pkthdr.
 *
 * @param mempool               The mempool to initialize.
 * @param mbuf_pool             The mbuf pool to initialize.
 * @param num_blocks            The total number of mbufs in the pool.
 * @param block_size            The size of each mbuf.
 * @param name                  The name to give the mempool.
 * @param out_buf               On success, this points to the malloced memory.
 *                                  Pass NULL if you don't need this
 *                                  information.
 *
 * @return                      0 on success;
 *                              DPL_ENOMEM on malloc failure;
 *                              Other OS code on unexpected error.
 */
Mallocs a block of memory and initializes an mbuf pool to use it.  The
specified block_size indicates the size of an mbuf acquired from the pool if
it does not contain a pkthdr.

@param mempool               The mempool to initialize.
@param mbuf_pool             The mbuf pool to initialize.
@param num_blocks            The total number of mbufs in the pool.
@param block_size            The size of each mbuf.
@param name                  The name to give the mempool.
@param out_buf               On success, this points to the malloced memory.
Pass NULL if you don't need this
information.

@return                      0 on success;
DPL_ENOMEM on malloc failure;
Other OS code on unexpected error.
Mallocs a block of memory and initializes an mbuf pool to use it . The specified block_size indicates the size of an mbuf acquired from the pool if it does not contain a pkthdr . @param mempool The mempool to initialize . @param mbuf_pool The mbuf pool to initialize . @param num_blocks The total number of mbufs in the pool . @param block_size The size of each mbuf . @param name The name to give the mempool . @param out_buf On success this points to the malloced memory . Pass NULL if you don ' t need this information . @return 0 on success ; DPL_ENOMEM on malloc failure ; Other OS code on unexpected error .
int
mem_malloc_mbuf_pool(struct dpl_mempool *mempool,
                     struct dpl_mbuf_pool *mbuf_pool, uint16_t num_blocks,
                     uint32_t block_size, char *name,
                     void **out_buf)
{
    void *buf;
    int rc;
    block_size = DPL_ALIGN(block_size + sizeof (struct dpl_mbuf), DPL_ALIGNMENT);
    rc = mem_malloc_mempool(mempool, num_blocks, block_size, name, &buf);
    if (rc != 0) {
        return rc;
    }
    rc = dpl_mbuf_pool_init(mbuf_pool, mempool, block_size, num_blocks);
    if (rc != 0) {
        free(buf);
        return rc;
    }
    if (out_buf != NULL) {
        *out_buf = buf;
    }
    return 0;
}
int mem_malloc_mbuf_pool ( struct dpl_mempool * mempool , struct dpl_mbuf_pool * mbuf_pool , uint16_t num_blocks , uint32_t block_size , char * name , void * * out_buf ) { void * buf ; int rc ; block_size = DPL_ALIGN ( block_size + sizeof ( struct dpl_mbuf ) , DPL_ALIGNMENT ) ; rc = mem_malloc_mempool ( mempool , num_blocks , block_size , name , & buf ) ; if ( rc != 0 ) { return rc ; } rc = dpl_mbuf_pool_init ( mbuf_pool , mempool , block_size , num_blocks ) ; if ( rc != 0 ) { free ( buf ) ; return rc ; } if ( out_buf != NULL ) { * out_buf = buf ; } return 0 ; }
Mallocs a block of memory and initializes an mbuf pool to use it.
Mallocs a block of memory and initializes an mbuf pool to use it .