| 340 | } |
| 341 | |
| 342 | error_code sys_memory_container_destroy(cpu_thread &cpu, u32 cid) { |
| 343 | cpu.state += cpu_flag::wait; |
| 344 | |
| 345 | sys_memory.warning("sys_memory_container_destroy(cid=0x%x)", cid); |
| 346 | |
| 347 | std::lock_guard lock(s_memstats_mtx); |
| 348 | |
| 349 | const auto ct = idm::withdraw<lv2_memory_container>( |
| 350 | cid, [](lv2_memory_container &ct) -> CellError { |
| 351 | // Check if some memory is not deallocated (the container cannot be |
| 352 | // destroyed in this case) |
| 353 | if (!ct.used.compare_and_swap_test(0, ct.size)) { |
| 354 | return CELL_EBUSY; |
| 355 | } |
| 356 | |
| 357 | return {}; |
| 358 | }); |
| 359 | |
| 360 | if (!ct) { |
| 361 | return CELL_ESRCH; |
| 362 | } |
| 363 | |
| 364 | if (ct.ret) { |
| 365 | return ct.ret; |
| 366 | } |
| 367 | |
| 368 | // Return "physical memory" to the default container |
| 369 | g_fxo->get<lv2_memory_container>().free(ct->size); |
| 370 | |
| 371 | return CELL_OK; |
| 372 | } |
| 373 | |
| 374 | error_code sys_memory_container_get_size(cpu_thread &cpu, |
| 375 | vm::ptr<sys_memory_info_t> mem_info, |
no test coverage detected