MCPcopy Create free account
hub / github.com/defold/defold / PatchBytes

Function PatchBytes

engine/gameobject/src/gameobject/res_lua.cpp:24–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace dmGameObject
23{
24 void PatchBytes(uint8_t* bytes, uint32_t bytes_size, const uint8_t* delta, uint32_t delta_size)
25 {
26 uint32_t i = 0;
27 while (i < delta_size) {
28 // get the index
29 uint32_t index = delta[i++];
30 if (bytes_size >= (1 << 24))
31 {
32 index += ((delta[i++]) << 8);
33 index += ((delta[i++]) << 16);
34 index += ((delta[i++]) << 24);
35 }
36 else if (bytes_size >= (1 << 16))
37 {
38 index += ((delta[i++]) << 8);
39 index += ((delta[i++]) << 16);
40 }
41 else if (bytes_size >= (1 << 8))
42 {
43 index += ((delta[i++]) << 8);
44 }
45
46 // get the number of consecutive bytes of changes
47 uint32_t count = delta[i++];
48 while (count-- > 0)
49 {
50 // apply the delta to the bytes
51 bytes[index++] = delta[i++];
52 }
53 }
54 }
55
56 void PatchLuaBytecode(dmLuaDDF::LuaSource *source)
57 {

Callers 2

PatchLuaBytecodeFunction · 0.85
TESTFunction · 0.85

Calls

no outgoing calls

Tested by 1

TESTFunction · 0.68