Changeset 11014 in vbox for trunk/include
- Timestamp:
- Jul 30, 2008 9:27:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mem.h
r11011 r11014 382 382 */ 383 383 template <class T> 384 inline void RTMemAuto Free(T *aMem)384 inline void RTMemAutoDestructor(T *aMem) 385 385 { 386 386 RTMemFree(aMem); 387 } 388 389 390 /** 391 * RTMemAutoPtr allocator which uses RTMemTmpAlloc(). 392 * 393 * @returns Allocated memory on success, NULL on failure. 394 * @param pvOld What to reallocate, shall always be NULL. 395 * @param cbNew The amount of memory to allocate (in bytes). 396 */ 397 inline void *RTMemTmpAutoAllocator(void *pvOld, size_t cbNew) 398 { 399 AssertReturn(!pvOld, NULL); 400 return RTMemTmpAlloc(cbNew); 401 } 402 403 404 /** 405 * Template function wrapping RTMemTmpFree to get the correct Destruct 406 * signature for RTAutoRes. 407 * 408 * We can't use a more complex template here, because the g++ on RHEL 3 409 * chokes on it with an internal compiler error. 410 * 411 * @param T The data type that's being managed. 412 * @param aMem Pointer to the memory that should be free. 413 */ 414 template <class T> 415 inline void RTMemTmpAutoDestructor(T *aMem) 416 { 417 RTMemTmpFree(aMem); 418 } 419 420 421 422 /** 423 * Template function wrapping RTMemEfFree to get the correct Destruct 424 * signature for RTAutoRes. 425 * 426 * We can't use a more complex template here, because the g++ on RHEL 3 427 * chokes on it with an internal compiler error. 428 * 429 * @param T The data type that's being managed. 430 * @param aMem Pointer to the memory that should be free. 431 */ 432 template <class T> 433 inline void RTMemEfAutoFree(T *aMem) 434 { 435 RTMemEfFree(aMem); 387 436 } 388 437 … … 423 472 * This will default to RTMemRealloc. 424 473 */ 425 template <class T, void Destruct(T *) = RTMemAuto Free<T>, void *Allocator(void *, size_t) = RTMemRealloc >474 template <class T, void Destruct(T *) = RTMemAutoDestructor<T>, void *Allocator(void *, size_t) = RTMemRealloc > 426 475 class RTMemAutoPtr 427 476 : public RTAutoRes<T *, Destruct, RTMemAutoNil<T> > … … 543 592 }; 544 593 594 545 595 #endif /* __cplusplus */ 546 596
Note:
See TracChangeset
for help on using the changeset viewer.