Changeset 11017 in vbox for trunk/include
- Timestamp:
- Jul 30, 2008 10:27:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mem.h
r11014 r11017 488 488 489 489 /** 490 * Constructor that 490 * Constructor that allocates memory. 491 491 * 492 492 * @param a_cElements The number of elements (of the data type) to allocate. … … 495 495 */ 496 496 RTMemAutoPtr(size_t a_cElements, bool a_fZeroed = false) 497 : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)NULL) 498 { 499 alloc(a_cElements, a_fZeroed); 497 : RTAutoRes<T *, Destruct, RTMemAutoNil<T> >((T *)Allocator(NULL, a_cElements * sizeof(T))) 498 { 499 if (a_fZeroed && RT_LIKELY(this->get() != NULL)) 500 memset(this->get(), '\0', a_cElements * sizeof(T)); 500 501 } 501 502 … … 509 510 this->RTAutoRes<T *, Destruct, RTMemAutoNil<T> >::operator=(aPtr); 510 511 return *this; 511 512 } 512 513 513 514 /** … … 557 558 this->reset(NULL); 558 559 T *pNewMem = (T *)Allocator(NULL, a_cElements * sizeof(T)); 559 if (a_fZeroed && pNewMem)560 if (a_fZeroed && RT_LIKELY(pNewMem != NULL)) 560 561 memset(pNewMem, '\0', a_cElements * sizeof(T)); 561 562 this->reset(pNewMem); … … 584 585 { 585 586 T *aNewValue = (T *)Allocator(this->get(), a_cElements * sizeof(T)); 586 if ( aNewValue != NULL)587 if (RT_LIKELY(aNewValue != NULL)) 587 588 this->release(); 588 589 /* We want this both if aNewValue is non-NULL and if it is NULL. */
Note:
See TracChangeset
for help on using the changeset viewer.