少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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);
}