Changeset 10980 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Jul 30, 2008 1:13:20 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp
r10976 r10980 533 533 { 534 534 int rc = VINF_SUCCESS; 535 RTMemAutoPtr<VBGLR3GUESTPROPENUM, VbglR3GuestPropEnumFree> apHandle; 536 apHandle = reinterpret_cast<PVBGLR3GUESTPROPENUM>( 537 RTMemAllocZ(sizeof(VBGLR3GUESTPROPENUM)) 538 ); 539 if (NULL == apHandle.get()) 535 RTMemAutoPtr<VBGLR3GUESTPROPENUM, VbglR3GuestPropEnumFree> Handle; 536 Handle = RTMemAllocZ(sizeof(VBGLR3GUESTPROPENUM)); 537 if (!Handle) 540 538 rc = VERR_NO_MEMORY; 541 539 … … 545 543 cchPatterns += strlen(papszPatterns[i]) + 1; 546 544 /* Pack the pattern array */ 547 RTMemAutoPtr<char> pPatterns;548 pPatterns = reinterpret_cast<char *>(RTMemAlloc(cchPatterns));549 char *pchPatternsRaw = pPatterns.get();545 RTMemAutoPtr<char> Patterns; 546 Patterns = reinterpret_cast<char *>(RTMemAlloc(cchPatterns)); 547 size_t iOffs = 0; 550 548 for (int i = 0; i < cPatterns; ++i) 551 549 { 552 550 size_t cb = strlen(papszPatterns[i]) + 1; 553 memcpy( pchPatternsRaw, papszPatterns[i], cb);554 pchPatternsRaw+= cb;555 } 556 *pchPatternsRaw= '\0';551 memcpy(&Patterns[iOffs], papszPatterns[i], cb); 552 iOffs += cb; 553 } 554 Patterns[iOffs] = '\0'; 557 555 558 556 /* Randomly chosen initial size for the buffer to hold the enumeration 559 557 * information. */ 560 558 uint32_t cchBuf = 4096; 561 RTMemAutoPtr<char> pchBuf;559 RTMemAutoPtr<char> Buf; 562 560 /* In reading the guest property data we are racing against the host 563 561 * adding more of it, so loop a few times and retry on overflow. */ … … 566 564 for (int i = 0; (i < 10) && !finish; ++i) 567 565 { 568 if (! pchBuf.realloc<RTMemRealloc>(cchBuf))566 if (!Buf.realloc(cchBuf)) 569 567 rc = VERR_NO_MEMORY; 570 568 if (RT_SUCCESS(rc) || (VERR_BUFFER_OVERFLOW == rc)) 571 rc = VbglR3GuestPropEnumRaw(u32ClientId, pPatterns.get(),572 pchBuf.get(), cchBuf, &cchBuf);569 rc = VbglR3GuestPropEnumRaw(u32ClientId, Patterns.get(), 570 Buf.get(), cchBuf, &cchBuf); 573 571 if (rc != VERR_BUFFER_OVERFLOW) 574 572 finish = true; … … 581 579 { 582 580 /* Transfer ownership of the buffer to the handle structure. */ 583 apHandle->pchBuf = pchBuf.release();584 apHandle->cchBuf = cchBuf;585 } 586 if (RT_SUCCESS(rc)) 587 rc = VbglR3GuestPropEnumNext( apHandle.get(), ppszName, ppszValue,581 Handle->pchBuf = Buf.release(); 582 Handle->cchBuf = cchBuf; 583 } 584 if (RT_SUCCESS(rc)) 585 rc = VbglR3GuestPropEnumNext(Handle.get(), ppszName, ppszValue, 588 586 pu64Timestamp, ppszFlags); 589 587 if (RT_SUCCESS(rc) && (NULL == ppszName)) … … 592 590 /* And transfer ownership of the handle to the caller. */ 593 591 if (RT_SUCCESS(rc)) 594 *ppHandle = apHandle.release();592 *ppHandle = Handle.release(); 595 593 return rc; 596 594 }
Note:
See TracChangeset
for help on using the changeset viewer.