mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
minor code simplification
This commit is contained in:
parent
8f4e7f4961
commit
5fbfc0f9f7
|
@ -322,7 +322,6 @@ void memory::deallocate(void * p) {
|
||||||
|
|
||||||
void * memory::allocate(size_t s) {
|
void * memory::allocate(size_t s) {
|
||||||
s = s + sizeof(size_t); // we allocate an extra field!
|
s = s + sizeof(size_t); // we allocate an extra field!
|
||||||
bool out_of_mem = false, counts_exceeded = false;
|
|
||||||
{
|
{
|
||||||
lock_guard lock(*g_memory_mux);
|
lock_guard lock(*g_memory_mux);
|
||||||
g_memory_alloc_size += s;
|
g_memory_alloc_size += s;
|
||||||
|
@ -330,14 +329,10 @@ void * memory::allocate(size_t s) {
|
||||||
if (g_memory_alloc_size > g_memory_max_used_size)
|
if (g_memory_alloc_size > g_memory_max_used_size)
|
||||||
g_memory_max_used_size = g_memory_alloc_size;
|
g_memory_max_used_size = g_memory_alloc_size;
|
||||||
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
|
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
|
||||||
out_of_mem = true;
|
throw_out_of_memory();
|
||||||
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
|
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
|
||||||
counts_exceeded = true;
|
throw_alloc_counts_exceeded();
|
||||||
}
|
}
|
||||||
if (out_of_mem)
|
|
||||||
throw_out_of_memory();
|
|
||||||
if (counts_exceeded)
|
|
||||||
throw_alloc_counts_exceeded();
|
|
||||||
void * r = malloc(s);
|
void * r = malloc(s);
|
||||||
if (r == nullptr) {
|
if (r == nullptr) {
|
||||||
throw_out_of_memory();
|
throw_out_of_memory();
|
||||||
|
@ -352,7 +347,6 @@ void* memory::reallocate(void *p, size_t s) {
|
||||||
size_t sz = *sz_p;
|
size_t sz = *sz_p;
|
||||||
void * real_p = reinterpret_cast<void*>(sz_p);
|
void * real_p = reinterpret_cast<void*>(sz_p);
|
||||||
s = s + sizeof(size_t); // we allocate an extra field!
|
s = s + sizeof(size_t); // we allocate an extra field!
|
||||||
bool out_of_mem = false, counts_exceeded = false;
|
|
||||||
{
|
{
|
||||||
lock_guard lock(*g_memory_mux);
|
lock_guard lock(*g_memory_mux);
|
||||||
g_memory_alloc_size += s - sz;
|
g_memory_alloc_size += s - sz;
|
||||||
|
@ -360,14 +354,10 @@ void* memory::reallocate(void *p, size_t s) {
|
||||||
if (g_memory_alloc_size > g_memory_max_used_size)
|
if (g_memory_alloc_size > g_memory_max_used_size)
|
||||||
g_memory_max_used_size = g_memory_alloc_size;
|
g_memory_max_used_size = g_memory_alloc_size;
|
||||||
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
|
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
|
||||||
out_of_mem = true;
|
throw_out_of_memory();
|
||||||
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
|
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
|
||||||
counts_exceeded = true;
|
throw_alloc_counts_exceeded();
|
||||||
}
|
}
|
||||||
if (out_of_mem)
|
|
||||||
throw_out_of_memory();
|
|
||||||
if (counts_exceeded)
|
|
||||||
throw_alloc_counts_exceeded();
|
|
||||||
void *r = realloc(real_p, s);
|
void *r = realloc(real_p, s);
|
||||||
if (r == nullptr) {
|
if (r == nullptr) {
|
||||||
throw_out_of_memory();
|
throw_out_of_memory();
|
||||||
|
|
Loading…
Reference in a new issue