diff options
Diffstat (limited to 'src/inc')
-rw-r--r-- | src/inc/clrhost.h | 13 | ||||
-rw-r--r-- | src/inc/stgpool.h | 36 |
2 files changed, 43 insertions, 6 deletions
diff --git a/src/inc/clrhost.h b/src/inc/clrhost.h index c210652a8d..88a917d59f 100644 --- a/src/inc/clrhost.h +++ b/src/inc/clrhost.h @@ -182,8 +182,11 @@ inline void ClrFlsSetValue(DWORD slot, void *pData) } } -typedef LPVOID (*FastAllocInProcessHeapFunc)(DWORD dwFlags, SIZE_T dwBytes); -extern FastAllocInProcessHeapFunc __ClrAllocInProcessHeap; +#ifndef SELF_NO_HOST +LPVOID EEHeapAllocInProcessHeap(DWORD dwFlags, SIZE_T dwBytes); +BOOL EEHeapFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem); +#endif + inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes) { STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; @@ -193,7 +196,7 @@ inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes) } #ifndef SELF_NO_HOST - return __ClrAllocInProcessHeap(dwFlags, dwBytes.Value()); + return EEHeapAllocInProcessHeap(dwFlags, dwBytes.Value()); #else #undef HeapAlloc #undef GetProcessHeap @@ -206,13 +209,11 @@ inline LPVOID ClrAllocInProcessHeap(DWORD dwFlags, S_SIZE_T dwBytes) #endif } -typedef BOOL (*FastFreeInProcessHeapFunc)(DWORD dwFlags, LPVOID lpMem); -extern FastFreeInProcessHeapFunc __ClrFreeInProcessHeap; inline BOOL ClrFreeInProcessHeap(DWORD dwFlags, LPVOID lpMem) { STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; #ifndef SELF_NO_HOST - return __ClrFreeInProcessHeap(dwFlags, lpMem); + return EEHeapFreeInProcessHeap(dwFlags, lpMem); #else #undef HeapFree #undef GetProcessHeap diff --git a/src/inc/stgpool.h b/src/inc/stgpool.h index 4486695507..67d78b24db 100644 --- a/src/inc/stgpool.h +++ b/src/inc/stgpool.h @@ -234,6 +234,42 @@ public: return hr; } + +//***************************************************************************** +// Return a pointer to a null terminated string given an offset previously +// handed out by AddString or FindString. Only valid for use if the Storage pool is actuall ReadOnly, and not derived +//***************************************************************************** + __checkReturn + inline HRESULT GetStringReadOnly( + UINT32 nIndex, + __deref_out LPCSTR *pszString) + { + HRESULT hr; + + // Size of the data in the heap will be ignored, because we have verified during creation of the string + // heap (code:Initialize) and when adding new strings (e.g. code:AddString, + // code:AddTemporaryStringBuffer), that the heap is null-terminated, therefore we don't have to check it + // for each string in the heap + MetaData::DataBlob stringData; + + // Get data from the heap (clears stringData on error) + IfFailGo(GetDataReadOnly( + nIndex, + &stringData)); + _ASSERTE(hr == S_OK); + // Raw data are always at least 1 byte long, otherwise it would be invalid offset and hr != S_OK + PREFAST_ASSUME(stringData.GetDataPointer() != NULL); + // Fills output string + *pszString = reinterpret_cast<LPSTR>(stringData.GetDataPointer()); + //_ASSERTE(stringData.GetSize() > strlen(*pszString)); + + return hr; + ErrExit: + // Clears output string on error + *pszString = NULL; + + return hr; + } #ifdef _PREFAST_ #pragma warning(pop) #endif |