Changeset 34240 in vbox
- Timestamp:
- Nov 22, 2010 2:24:49 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67988
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/CFGM.cpp
r34186 r34240 2655 2655 * @param ppszString Where to store the string pointer. Not set on failure. 2656 2656 * Free this using MMR3HeapFree(). 2657 * @param pszDef The default return value. This can be NULL. 2657 2658 */ 2658 2659 VMMR3DECL(int) CFGMR3QueryStringAllocDef(PCFGMNODE pNode, const char *pszName, char **ppszString, const char *pszDef) 2659 2660 { 2660 size_t cbString; 2661 int rc = CFGMR3QuerySize(pNode, pszName, &cbString); 2662 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) 2663 { 2664 cbString = strlen(pszDef) + 1; 2665 rc = VINF_SUCCESS; 2666 } 2667 if (RT_SUCCESS(rc)) 2668 { 2669 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbString); 2670 if (pszString) 2661 /* 2662 * (Don't call CFGMR3QuerySize and CFGMR3QueryStringDef here as the latter 2663 * cannot handle pszDef being NULL.) 2664 */ 2665 PCFGMLEAF pLeaf; 2666 int rc = cfgmR3ResolveLeaf(pNode, pszName, &pLeaf); 2667 if (RT_SUCCESS(rc)) 2668 { 2669 if (pLeaf->enmType == CFGMVALUETYPE_STRING) 2671 2670 { 2672 rc = CFGMR3QueryStringDef(pNode, pszName, pszString, cbString, pszDef); 2673 if (RT_SUCCESS(rc)) 2671 size_t const cbSrc = pLeaf->Value.String.cb; 2672 char *pszString = (char *)MMR3HeapAlloc(pNode->pVM, MM_TAG_CFGM_USER, cbSrc); 2673 if (pszString) 2674 { 2675 memcpy(pszString, pLeaf->Value.String.psz, cbSrc); 2674 2676 *ppszString = pszString; 2677 } 2675 2678 else 2676 MMR3HeapFree(pszString);2679 rc = VERR_NO_MEMORY; 2677 2680 } 2678 2681 else 2679 rc = VERR_NO_MEMORY; 2680 } 2682 rc = VERR_CFGM_NOT_STRING; 2683 } 2684 if (RT_FAILURE(rc)) 2685 { 2686 if (!pszDef) 2687 *ppszString = NULL; 2688 else 2689 *ppszString = MMR3HeapStrDup(pNode->pVM, MM_TAG_CFGM_USER, pszDef); 2690 if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) 2691 rc = VINF_SUCCESS; 2692 } 2693 2681 2694 return rc; 2682 2695 }
Note:
See TracChangeset
for help on using the changeset viewer.