MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / serialize

Function serialize

TheForceEngine/TFE_Memory/chunkedArray.cpp:41–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 void addFreeSlot(ChunkedArray* arr, u8* ptr);
40
41 void serialize(ChunkedArray* arr, FileStream* file)
42 {
43 assert(file);
44 size_t size = size_t(&arr->chunks) - sizeof(arr);
45 file->writeBuffer(arr, (u32)size);
46
47 const u32 chunkAllocSize = arr->elemPerChunk * arr->elemSize;
48 for (u32 i = 0; i < arr->chunkCount; i++)
49 {
50 file->write(arr->chunks[i], chunkAllocSize);
51 }
52
53 for (u32 i = 0; i < arr->freeSlotCount; i++)
54 {
55 s32 freeSlotIndex = getSlotIndex(arr, arr->freeSlots[i]);
56 file->write(&freeSlotIndex);
57 }
58 }
59
60 ChunkedArray* restore(FileStream* file, MemoryRegion* region)
61 {

Callers 1

serializeGameStateMethod · 0.50

Calls 3

getSlotIndexFunction · 0.85
writeBufferMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected