Changeset 69757 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Nov 19, 2017 3:15:36 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119157
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/dir.cpp
r69753 r69757 795 795 } 796 796 797 798 RTDECL(int) RTDirReadExA(RTDIR hDir, PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAddAttr, uint32_t fFlags) 799 { 800 PRTDIRENTRYEX pDirEntry = *ppDirEntry; 801 size_t cbDirEntry = *pcbDirEntry; 802 if (pDirEntry != NULL && cbDirEntry >= sizeof(RTDIRENTRYEX)) 803 { /* likely */ } 804 else 805 { 806 Assert(pDirEntry == NULL); 807 Assert(cbDirEntry == 0); 808 809 cbDirEntry = RT_ALIGN_Z(sizeof(RTDIRENTRYEX), 16); 810 *ppDirEntry = pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntry); 811 if (pDirEntry) 812 *pcbDirEntry = cbDirEntry; 813 else 814 { 815 *pcbDirEntry = 0; 816 return VERR_NO_TMP_MEMORY; 817 } 818 } 819 820 for (;;) 821 { 822 int rc = RTDirReadEx(hDir, pDirEntry, &cbDirEntry, enmAddAttr, fFlags); 823 if (rc != VERR_BUFFER_OVERFLOW) 824 return rc; 825 826 /* Grow the buffer. */ 827 RTMemTmpFree(pDirEntry); 828 cbDirEntry = RT_MAX(RT_ALIGN_Z(cbDirEntry, 64), *pcbDirEntry + 64); 829 *ppDirEntry = pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntry); 830 if (pDirEntry) 831 *pcbDirEntry = cbDirEntry; 832 else 833 { 834 *pcbDirEntry = 0; 835 return VERR_NO_TMP_MEMORY; 836 } 837 } 838 } 839 840 841 RTDECL(void) RTDirReadExAFree(PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry) 842 { 843 PRTDIRENTRYEX pDirEntry = *ppDirEntry; 844 if (pDirEntry != NULL && *pcbDirEntry >= sizeof(*pcbDirEntry)) 845 RTMemTmpFree(pDirEntry); 846 else 847 { 848 Assert(pDirEntry == NULL); 849 Assert(*pcbDirEntry == 0); 850 } 851 *ppDirEntry = NULL; 852 *pcbDirEntry = 0; 853 } 854
Note:
See TracChangeset
for help on using the changeset viewer.