/* * Copyright (c) 2022-2023, ArtInChip Technology Co., Ltd * * SPDX-License-Identifier: Apache-2.0 * * author: qi.xu@artinchip.com * Desc: virtual memory allocator */ #include #include #include #include #include "aic_core.h" #include "mpp_mem.h" #include "mpp_log.h" #define DEBUG_MEM (0) #if DEBUG_MEM #include #define MAX_NUM 20 struct memory_node { void* addr; int size; int used; }; static pthread_mutex_t g_mem_mutex = PTHREAD_MUTEX_INITIALIZER; int g_mem_count = 0; int g_mem_total_size = 0; struct memory_node g_mem_info[MAX_NUM] = {{0,0,0}}; #endif void *mpp_alloc(size_t size) { void *ptr = NULL; ptr = aicos_malloc(MEM_DEFAULT, size); #if DEBUG_MEM int i = 0; pthread_mutex_lock(&g_mem_mutex); g_mem_count ++; g_mem_total_size += size; for(i=0; i