< prev index next >

src/share/vm/memory/allocation.cpp

Print this page
rev 7793 : 8073315: Enable gcc -Wtype-limits and fix upcoming issues.


 544   _chunk = new (alloc_failmode, len) Chunk(len);
 545 
 546   if (_chunk == NULL) {
 547     _chunk = k;                 // restore the previous value of _chunk
 548     return NULL;
 549   }
 550   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
 551   else _first = _chunk;
 552   _hwm  = _chunk->bottom();     // Save the cached hwm, max
 553   _max =  _chunk->top();
 554   set_size_in_bytes(size_in_bytes() + len);
 555   void* result = _hwm;
 556   _hwm += x;
 557   return result;
 558 }
 559 
 560 
 561 
 562 // Reallocate storage in Arena.
 563 void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
 564   assert(new_size >= 0, "bad size");
 565   if (new_size == 0) return NULL;
 566 #ifdef ASSERT
 567   if (UseMallocOnly) {
 568     // always allocate a new object  (otherwise we'll free this one twice)
 569     char* copy = (char*)Amalloc(new_size, alloc_failmode);
 570     if (copy == NULL) {
 571       return NULL;
 572     }
 573     size_t n = MIN2(old_size, new_size);
 574     if (n > 0) memcpy(copy, old_ptr, n);
 575     Afree(old_ptr,old_size);    // Mostly done to keep stats accurate
 576     return copy;
 577   }
 578 #endif
 579   char *c_old = (char*)old_ptr; // Handy name
 580   // Stupid fast special case
 581   if( new_size <= old_size ) {  // Shrink in-place
 582     if( c_old+old_size == _hwm) // Attempt to free the excess bytes
 583       _hwm = c_old+new_size;    // Adjust hwm
 584     return c_old;




 544   _chunk = new (alloc_failmode, len) Chunk(len);
 545 
 546   if (_chunk == NULL) {
 547     _chunk = k;                 // restore the previous value of _chunk
 548     return NULL;
 549   }
 550   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
 551   else _first = _chunk;
 552   _hwm  = _chunk->bottom();     // Save the cached hwm, max
 553   _max =  _chunk->top();
 554   set_size_in_bytes(size_in_bytes() + len);
 555   void* result = _hwm;
 556   _hwm += x;
 557   return result;
 558 }
 559 
 560 
 561 
 562 // Reallocate storage in Arena.
 563 void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {

 564   if (new_size == 0) return NULL;
 565 #ifdef ASSERT
 566   if (UseMallocOnly) {
 567     // always allocate a new object  (otherwise we'll free this one twice)
 568     char* copy = (char*)Amalloc(new_size, alloc_failmode);
 569     if (copy == NULL) {
 570       return NULL;
 571     }
 572     size_t n = MIN2(old_size, new_size);
 573     if (n > 0) memcpy(copy, old_ptr, n);
 574     Afree(old_ptr,old_size);    // Mostly done to keep stats accurate
 575     return copy;
 576   }
 577 #endif
 578   char *c_old = (char*)old_ptr; // Handy name
 579   // Stupid fast special case
 580   if( new_size <= old_size ) {  // Shrink in-place
 581     if( c_old+old_size == _hwm) // Attempt to free the excess bytes
 582       _hwm = c_old+new_size;    // Adjust hwm
 583     return c_old;


< prev index next >