mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-25 05:50:17 +00:00
rollback fix init
This commit is contained in:
parent
40f95580d3
commit
15c254ab87
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
void init_memory_pools_if_needed();
|
|
||||||
|
|
||||||
void* pool64_alloc(size_t) noexcept;
|
void* pool64_alloc(size_t) noexcept;
|
||||||
void pool64_dealloc(void*) noexcept;
|
void pool64_dealloc(void*) noexcept;
|
||||||
|
|
||||||
|
|||||||
@ -267,26 +267,21 @@ struct MemoryPool{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static MemoryPool<64>* pool64 = nullptr;
|
static MemoryPool<64> pool64;
|
||||||
static MemoryPool<128>* pool128 = nullptr;
|
static MemoryPool<128> pool128;
|
||||||
|
|
||||||
void init_memory_pools_if_needed(){
|
void* pool64_alloc(size_t size) noexcept { return pool64.alloc(size); }
|
||||||
if(pool64 == nullptr) pool64 = new MemoryPool<64>();
|
void pool64_dealloc(void* p) noexcept { pool64.dealloc(p); }
|
||||||
if(pool128 == nullptr) pool128 = new MemoryPool<128>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void* pool64_alloc(size_t size) noexcept { return pool64->alloc(size); }
|
void* pool128_alloc(size_t size) noexcept { return pool128.alloc(size); }
|
||||||
void pool64_dealloc(void* p) noexcept { pool64->dealloc(p); }
|
void pool128_dealloc(void* p) noexcept { pool128.dealloc(p); }
|
||||||
|
|
||||||
void* pool128_alloc(size_t size) noexcept { return pool128->alloc(size); }
|
|
||||||
void pool128_dealloc(void* p) noexcept { pool128->dealloc(p); }
|
|
||||||
|
|
||||||
void pools_shrink_to_fit() noexcept {
|
void pools_shrink_to_fit() noexcept {
|
||||||
pool64->shrink_to_fit();
|
pool64.shrink_to_fit();
|
||||||
pool128->shrink_to_fit();
|
pool128.shrink_to_fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pool64_info() noexcept { return pool64->info(); }
|
std::string pool64_info() noexcept { return pool64.info(); }
|
||||||
std::string pool128_info() noexcept { return pool128->info(); }
|
std::string pool128_info() noexcept { return pool128.info(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -73,7 +73,6 @@ namespace pkpy{
|
|||||||
};
|
};
|
||||||
|
|
||||||
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
|
VM::VM(bool enable_os) : heap(this), enable_os(enable_os) {
|
||||||
init_memory_pools_if_needed();
|
|
||||||
this->vm = this;
|
this->vm = this;
|
||||||
this->_c.error = nullptr;
|
this->_c.error = nullptr;
|
||||||
_stdout = [](const char* buf, int size) { std::cout.write(buf, size); };
|
_stdout = [](const char* buf, int size) { std::cout.write(buf, size); };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user