mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
mempool:remove multiple fixed api
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
@@ -423,64 +423,6 @@ FAR void *mempool_multiple_memalign(FAR struct mempool_multiple_s *mpool,
|
|||||||
void mempool_multiple_memdump(FAR struct mempool_multiple_s *mpool,
|
void mempool_multiple_memdump(FAR struct mempool_multiple_s *mpool,
|
||||||
pid_t pid);
|
pid_t pid);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_alloc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Allocate an block from specific multiple memory pool.
|
|
||||||
* If the mempool of the corresponding size doesn't have free block,
|
|
||||||
* then wait until free happened or return NULL.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* The pointer to the allocated block on success; NULL on any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
FAR void *mempool_multiple_fixed_alloc(FAR struct mempool_multiple_s *mpool,
|
|
||||||
size_t size);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_realloc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Change the size of the block memory pointed to by oldblk to size bytes.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* oldblk - The pointer to change the size of the block memory.
|
|
||||||
* oldsize - The size of block memory to oldblk.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* The pointer to the allocated block on success; NULL on any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
FAR void *
|
|
||||||
mempool_multiple_fixed_realloc(FAR struct mempool_multiple_s *mpool,
|
|
||||||
FAR void *oldblk, size_t oldsize,
|
|
||||||
size_t size);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_free
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Release an memory block to the multiple mempry pool. The blk must have
|
|
||||||
* been returned by a previous call to mempool_multiple_fixed_alloc.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* blk - The pointer of memory block.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void mempool_multiple_fixed_free(FAR struct mempool_multiple_s *mpool,
|
|
||||||
FAR void *blk, size_t size);
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mempool_multiple_deinit
|
* Name: mempool_multiple_deinit
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -406,101 +406,6 @@ void mempool_multiple_memdump(FAR struct mempool_multiple_s *mpool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_alloc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Allocate an block from specific multiple memory pool.
|
|
||||||
* If the mempool of the corresponding size doesn't have free block,
|
|
||||||
* then wait until free happened or return NULL.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* The pointer to the allocated block on success; NULL on any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
FAR void *mempool_multiple_fixed_alloc(FAR struct mempool_multiple_s *mpool,
|
|
||||||
size_t size)
|
|
||||||
{
|
|
||||||
FAR struct mempool_s *pool;
|
|
||||||
|
|
||||||
pool = mempool_multiple_find(mpool, size);
|
|
||||||
if (pool == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mempool_alloc(pool);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_realloc
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Change the size of the block memory pointed to by oldblk to size bytes.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* oldblk - The pointer to change the size of the block memory.
|
|
||||||
* oldsize - The size of block memory to oldblk.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* The pointer to the allocated block on success; NULL on any failure.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
FAR void *
|
|
||||||
mempool_multiple_fixed_realloc(FAR struct mempool_multiple_s *mpool,
|
|
||||||
FAR void *oldblk, size_t oldsize, size_t size)
|
|
||||||
{
|
|
||||||
FAR void *blk;
|
|
||||||
|
|
||||||
if (size < 1)
|
|
||||||
{
|
|
||||||
mempool_multiple_fixed_free(mpool, oldblk, oldsize);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
blk = mempool_multiple_fixed_alloc(mpool, size);
|
|
||||||
if (blk != NULL && oldblk != NULL)
|
|
||||||
{
|
|
||||||
memcpy(blk, oldblk, MIN(oldsize, size));
|
|
||||||
mempool_multiple_fixed_free(mpool, oldblk, oldsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return blk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: mempool_multiple_fixed_free
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Release an memory block to the multiple mempry pool. The blk must have
|
|
||||||
* been returned by a previous call to mempool_multiple_fixed_alloc.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* mpool - The handle of multiple memory pool to be used.
|
|
||||||
* blk - The pointer of memory block.
|
|
||||||
* size - The size of alloc blk.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void mempool_multiple_fixed_free(FAR struct mempool_multiple_s *mpool,
|
|
||||||
FAR void *blk, size_t size)
|
|
||||||
{
|
|
||||||
FAR struct mempool_s *pool;
|
|
||||||
|
|
||||||
DEBUGASSERT(mpool != NULL && blk != NULL);
|
|
||||||
|
|
||||||
pool = mempool_multiple_find(mpool, size);
|
|
||||||
DEBUGASSERT(pool != NULL);
|
|
||||||
mempool_free(pool, blk);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mempool_multiple_deinit
|
* Name: mempool_multiple_deinit
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user