mirror of
https://github.com/rockchip-linux/mpp.git
synced 2024-11-24 10:33:34 +08:00
[osal]: add mpp_calloc function
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@101 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
parent
268db1363f
commit
63880b5333
@ -27,6 +27,9 @@
|
||||
#define mpp_malloc(type, count) \
|
||||
(type*)mpp_osal_malloc(MODULE_TAG, sizeof(type) * (count))
|
||||
|
||||
#define mpp_calloc(type, count) \
|
||||
(type*)mpp_osal_calloc(MODULE_TAG, sizeof(type) * (count))
|
||||
|
||||
#define mpp_realloc(ptr, type, count) \
|
||||
(type*)mpp_osal_realloc(MODULE_TAG, ptr, sizeof(type) * (count))
|
||||
|
||||
@ -38,6 +41,7 @@ extern "C" {
|
||||
|
||||
void mpp_show_mem_status();
|
||||
void *mpp_osal_malloc(char *tag, size_t size);
|
||||
void *mpp_osal_calloc(char *tag, size_t size);
|
||||
void *mpp_osal_realloc(char *tag, void *ptr, size_t size);
|
||||
void mpp_osal_free(void *ptr);
|
||||
|
||||
|
@ -89,6 +89,14 @@ void *mpp_osal_malloc(char *tag, size_t size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *mpp_osal_calloc(char *tag, size_t size)
|
||||
{
|
||||
void *ptr = mpp_osal_malloc(tag, size);
|
||||
if (ptr)
|
||||
memset(ptr, 0, size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *mpp_osal_realloc(char *tag, void *ptr, size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
@ -27,11 +27,11 @@ int main()
|
||||
void *tmp = NULL;
|
||||
|
||||
mpp_set_env_u32("osal_mem_list", 1);
|
||||
tmp = mpp_malloc(int, 100);
|
||||
tmp = mpp_calloc(int, 100);
|
||||
if (tmp) {
|
||||
mpp_log("malloc success ptr 0x%p\n", tmp);
|
||||
mpp_log("calloc success ptr 0x%p\n", tmp);
|
||||
} else {
|
||||
mpp_log("malloc failed\n");
|
||||
mpp_log("calloc failed\n");
|
||||
}
|
||||
if (tmp) {
|
||||
tmp = mpp_realloc(tmp, int, 200);
|
||||
|
Loading…
Reference in New Issue
Block a user