소스 검색

add rt_memory_info() for memheap.c

unknown 4 년 전
부모
커밋
b71a0eb1d4
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      src/memheap.c

+ 14 - 0
src/memheap.c

@@ -712,6 +712,20 @@ void *rt_calloc(rt_size_t count, rt_size_t size)
 }
 RTM_EXPORT(rt_calloc);
 
+void rt_memory_info(rt_uint32_t *total,
+                    rt_uint32_t *used,
+                    rt_uint32_t *max_used)
+{
+    if (total != RT_NULL)
+        *total = _heap.pool_size;
+
+    if (used  != RT_NULL)
+        *used = _heap.pool_size - _heap.available_size;
+
+    if (max_used != RT_NULL)
+        *max_used = _heap.max_used_size;
+}
+
 #endif
 
 #endif