Skip to content

Commit 0022d80

Browse files
committed
Add size tracking independent of storage buffer.
1 parent 7ba945e commit 0022d80

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

source/mock/ur_mock_helpers.hpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ namespace mock {
2424

2525
struct dummy_handle_t_ {
2626
dummy_handle_t_(size_t DataSize = 0)
27-
: MStorage(DataSize), MData(MStorage.data()) {}
28-
dummy_handle_t_(unsigned char *Data) : MData(Data) {}
27+
: MStorage(DataSize), MData(MStorage.data()), MSize(DataSize) {}
28+
dummy_handle_t_(unsigned char *Data, size_t Size)
29+
: MData(Data), MSize(Size) {}
2930
std::atomic<size_t> MRefCounter = 1;
3031
std::vector<unsigned char> MStorage;
3132
unsigned char *MData = nullptr;
33+
size_t MSize;
3234
};
3335

3436
using dummy_handle_t = dummy_handle_t_ *;
@@ -43,8 +45,9 @@ template <class T> inline T createDummyHandle(size_t Size = 0) {
4345

4446
// Allocates a dummy handle of type T with support of reference counting
4547
// and associates it with the provided Data.
46-
template <class T> inline T createDummyHandleWithData(unsigned char *Data) {
47-
auto DummyHandlePtr = new dummy_handle_t_(Data);
48+
template <class T>
49+
inline T createDummyHandleWithData(unsigned char *Data, size_t Size) {
50+
auto DummyHandlePtr = new dummy_handle_t_(Data, Size);
4851
return reinterpret_cast<T>(DummyHandlePtr);
4952
}
5053

0 commit comments

Comments
 (0)