Ticket #8986: sci-save-2.patch

File sci-save-2.patch, 872 bytes (added by wjp, 16 years ago)

Reallocate SegManager heap (apply on top of sci-save.patch)

  • engines/sci/engine/savegame.cpp

    diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
    index 253ce44..5f7aa9d 100644
    a b static void sync_menubar_t(Common::Serializer &s, menubar_t &obj) {  
    134134}
    135135
    136136static void sync_SegManager(Common::Serializer &s, SegManager &obj) {
     137        int allocated_heap_size = obj.heap_size;
    137138        s.syncAsSint32LE(obj.heap_size);
    138139        s.syncAsSint32LE(obj.reserved_id);
    139140        s.syncAsSint32LE(obj.exports_wide);
    static void sync_SegManager(Common::Serializer &s, SegManager &obj) {  
    143144        sync_IntMapper(s, *obj.id_seg_map);
    144145
    145146        assert(obj.heap);
     147        if (allocated_heap_size != obj.heap_size)
     148                obj.heap = (MemObject**)sci_realloc((void *)obj.heap, obj.heap_size * sizeof(MemObject *));
     149
    146150        for (int i = 0; i < obj.heap_size; ++i)
    147151                sync_MemObjPtr(s, obj.heap[i]);
    148152