forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmono-structs.cpp
More file actions
46 lines (38 loc) · 1017 Bytes
/
mono-structs.cpp
File metadata and controls
46 lines (38 loc) · 1017 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "mono-structs.h"
#include "os/c-api/il2cpp-config-platforms.h"
#include "os/c-api/Allocator.h"
MonoGPtrArray* void_ptr_array_to_gptr_array(const VoidPtrArray& array)
{
MonoGPtrArray *pRetVal;
pRetVal = (MonoGPtrArray*)Allocator::Allocate(sizeof(MonoGPtrArray));
pRetVal->len = (unsigned int)array.size();
if (pRetVal->len > 0)
{
size_t numBytes = sizeof(void*) * pRetVal->len;
pRetVal->pdata = Allocator::Allocate(numBytes);
memcpy(pRetVal->pdata, array.data(), numBytes);
}
else
{
pRetVal->pdata = NULL;
}
return pRetVal;
}
MonoGPtrArray* empty_gptr_array()
{
MonoGPtrArray *pRetVal = (MonoGPtrArray*)Allocator::Allocate(sizeof(MonoGPtrArray));
pRetVal->len = 0;
pRetVal->pdata = NULL;
return pRetVal;
}
void free_gptr_array(MonoGPtrArray *pArray)
{
if (!pArray)
return;
if (pArray->pdata)
{
IL2CPP_FREE(pArray->pdata);
pArray->pdata = NULL;
}
IL2CPP_FREE(pArray);
}