Ejemplo n.º 1
0
/************************************************************************
* NAME: fnet_heap_init
*
* DESCRIPTION: Heap init
*              
*************************************************************************/
int fnet_heap_init( unsigned char *heap_ptr, unsigned long heap_size )
{
    int result;


/* Init memory pools. */
#if FNET_HEAP_SPLIT
    if(((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0) &&
       ((fnet_mempool_netbuf = fnet_mempool_init( (void*)((unsigned long)fnet_malloc( FNET_NETBUF_MEMPOOL_SIZE(heap_size))), 
                                                    FNET_NETBUF_MEMPOOL_SIZE(heap_size), FNET_MEMPOOL_ALIGN_8 )) != 0) )

#else
     if((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0)
#endif
        result = FNET_OK;
     else
        result = FNET_ERR;  
                                                             
   
    return result;
}
Ejemplo n.º 2
0
/************************************************************************
* NAME: fnet_heap_init
*
* DESCRIPTION: Heap init
*              
*************************************************************************/
fnet_return_t fnet_heap_init( void *heap_ptr, fnet_size_t heap_size )
{
    fnet_return_t result;

/* Init memory pools. */
#if FNET_HEAP_SPLIT
    if(((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0) &&
       ((fnet_mempool_netbuf = fnet_mempool_init( (void*)((fnet_uint32_t)fnet_malloc( FNET_NETBUF_MEMPOOL_SIZE(heap_size))), 
                                                    FNET_NETBUF_MEMPOOL_SIZE(heap_size), FNET_MEMPOOL_ALIGN_8 )) != 0) )

#else
     if((fnet_mempool_main = fnet_mempool_init( heap_ptr, heap_size, FNET_MEMPOOL_ALIGN_8 )) != 0)
#endif
    {
        result = FNET_OK;
    }
    else
    {
        result = FNET_ERR;  
    }

    return result;
}