jitcraft/PoolAllocator.cpp
changeset 69 dfce0539a77d
parent 59 b7d61ddb3c8d
     1.1 --- a/jitcraft/PoolAllocator.cpp	Tue Jul 10 02:11:13 2012 -0700
     1.2 +++ b/jitcraft/PoolAllocator.cpp	Wed Jul 11 01:12:54 2012 -0700
     1.3 @@ -92,8 +92,10 @@
     1.4          reserved_ = NULL;
     1.5      } else {
     1.6          pool = (Pool *)malloc(bytesNeeded);
     1.7 -        if (!pool)
     1.8 -            throw std::bad_alloc();
     1.9 +        if (!pool) {
    1.10 +            ZONE()->reportOutOfMemory();
    1.11 +            return NULL;
    1.12 +        }
    1.13          pool->base = (char *)(pool + 1);
    1.14          pool->end = (char *)pool + bytesNeeded;
    1.15      }
    1.16 @@ -106,24 +108,19 @@
    1.17  void
    1.18  PoolAllocationPolicy::reportOutOfMemory()
    1.19  {
    1.20 -    // :TODO: report
    1.21 -    assert(false);
    1.22 +    ZONE()->reportOutOfMemory();
    1.23  }
    1.24  
    1.25  void
    1.26  PoolAllocationPolicy::reportAllocationOverflow()
    1.27  {
    1.28 -    // :TODO: report
    1.29 -    assert(false);
    1.30 +    ZONE()->reportError(Message_AllocationOverflow);
    1.31  }
    1.32  
    1.33  void *
    1.34  PoolAllocationPolicy::malloc(size_t bytes)
    1.35  {
    1.36 -    void *ptr = ZONE()->pool().allocate(bytes);
    1.37 -    if (!ptr)
    1.38 -        reportOutOfMemory();
    1.39 -    return ptr;
    1.40 +    return ZONE()->pool().allocate(bytes);
    1.41  }
    1.42  
    1.43  void