@@ -322,22 +322,17 @@ void memory::deallocate(void * p) {
322
322
323
323
void * memory::allocate (size_t s) {
324
324
s = s + sizeof (size_t ); // we allocate an extra field!
325
- bool out_of_mem = false , counts_exceeded = false ;
326
325
{
327
326
lock_guard lock (*g_memory_mux);
328
327
g_memory_alloc_size += s;
329
328
g_memory_alloc_count += 1 ;
330
329
if (g_memory_alloc_size > g_memory_max_used_size)
331
330
g_memory_max_used_size = g_memory_alloc_size;
332
331
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
333
- out_of_mem = true ;
332
+ throw_out_of_memory () ;
334
333
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
335
- counts_exceeded = true ;
334
+ throw_alloc_counts_exceeded () ;
336
335
}
337
- if (out_of_mem)
338
- throw_out_of_memory ();
339
- if (counts_exceeded)
340
- throw_alloc_counts_exceeded ();
341
336
void * r = malloc (s);
342
337
if (r == nullptr ) {
343
338
throw_out_of_memory ();
@@ -352,22 +347,17 @@ void* memory::reallocate(void *p, size_t s) {
352
347
size_t sz = *sz_p;
353
348
void * real_p = reinterpret_cast <void *>(sz_p);
354
349
s = s + sizeof (size_t ); // we allocate an extra field!
355
- bool out_of_mem = false , counts_exceeded = false ;
356
350
{
357
351
lock_guard lock (*g_memory_mux);
358
352
g_memory_alloc_size += s - sz;
359
353
g_memory_alloc_count += 1 ;
360
354
if (g_memory_alloc_size > g_memory_max_used_size)
361
355
g_memory_max_used_size = g_memory_alloc_size;
362
356
if (g_memory_max_size != 0 && g_memory_alloc_size > g_memory_max_size)
363
- out_of_mem = true ;
357
+ throw_out_of_memory () ;
364
358
if (g_memory_max_alloc_count != 0 && g_memory_alloc_count > g_memory_max_alloc_count)
365
- counts_exceeded = true ;
359
+ throw_alloc_counts_exceeded () ;
366
360
}
367
- if (out_of_mem)
368
- throw_out_of_memory ();
369
- if (counts_exceeded)
370
- throw_alloc_counts_exceeded ();
371
361
void *r = realloc (real_p, s);
372
362
if (r == nullptr ) {
373
363
throw_out_of_memory ();
0 commit comments