xx
This commit is contained in:
1 parent
541738319d
commit
83f6dde860
12 files changed
+68
-22
No files matched your search
@@ -344,6 +344,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
||||
rt_err_t rt_memheap_detach(struct rt_memheap *heap);
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_size_t size);
|
||||
void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize);
|
||||
void *rt_memheap_calloc(struct rt_memheap *heap, rt_size_t count, rt_size_t size);
|
||||
void rt_memheap_free(void *ptr);
|
||||
void rt_memheap_info(struct rt_memheap *heap,
|
||||
rt_size_t *total,
|
||||
|
||||
@@ -585,6 +585,33 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
|
||||
}
|
||||
RTM_EXPORT(rt_memheap_realloc);
|
||||
|
||||
/**
|
||||
* @brief This function will allocate a block of memory from the specified memheap,
|
||||
* and initialize all bytes in the allocated block to zero.
|
||||
*
|
||||
* @param heap is a pointer to the memheap object from which to allocate memory.
|
||||
*
|
||||
* @param count is the number of elements to allocate.
|
||||
*
|
||||
* @param size is the size of each element.
|
||||
*
|
||||
* @return the allocated memory block address, or RT_NULL on failure.
|
||||
*/
|
||||
void *rt_memheap_calloc(struct rt_memheap *heap, rt_size_t count, rt_size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
/* allocate 'count' objects of size 'size' */
|
||||
p = rt_memheap_alloc(heap,count * size);
|
||||
/* zero the memory */
|
||||
if (p)
|
||||
{
|
||||
rt_memset(p, 0, count * size);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
RTM_EXPORT(rt_memheap_calloc);
|
||||
|
||||
/**
|
||||
* @brief This function will release the allocated memory block by
|
||||
* rt_malloc. The released memory block is taken back to system heap.
|
||||
|
||||
Reference in new issue
Block a user