free.cpp
1 #include "coreutils.h" 2 #include <services/system.h> 3 4 #include <stdio.h> 5 6 int programs::coreutils::cmd_free(int argc, char **argv) { 7 (void)argv; 8 if (argc != 1) { printf("usage: free\n"); return 1; } 9 10 SystemQuery query = { 11 .preferred_storage = StorageKind::LittleFS, 12 .snapshot = {}, 13 }; 14 services::system::accessSnapshot(&query); 15 printf("heap total: %u\nheap free: %u\nheap used: %u\n", 16 query.snapshot.heap_total, query.snapshot.heap_free, 17 query.snapshot.heap_total - query.snapshot.heap_free); 18 return 0; 19 }