mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 14:50:17 +00:00
CGE: Fixed more free/delete[] mismatches identified by Valgrind
This commit is contained in:
parent
1870f09d31
commit
88c7b25e5b
@ -151,7 +151,7 @@ Bitmap::~Bitmap() {
|
||||
delete[](uint8 *) _v;
|
||||
break;
|
||||
case FAR_MEM :
|
||||
free(_v);
|
||||
delete[] _v;
|
||||
default:
|
||||
warning("Unhandled MemType in Bitmap destructor");
|
||||
break;
|
||||
@ -206,7 +206,7 @@ BMP_PTR Bitmap::code() {
|
||||
delete[](uint8 *) _v;
|
||||
break;
|
||||
case FAR_MEM :
|
||||
free(_v);
|
||||
delete[] _v;
|
||||
break;
|
||||
default:
|
||||
warning("Unhandled MemType in Bitmap::Code()");
|
||||
@ -294,7 +294,7 @@ BMP_PTR Bitmap::code() {
|
||||
break;
|
||||
|
||||
uint16 sizV = (uint16)(im - 2 - _v);
|
||||
_v = farnew(uint8, sizV + _h * sizeof(*_b));
|
||||
_v = new uint8[sizV + _h * sizeof(*_b)];
|
||||
if (!_v)
|
||||
error("No core");
|
||||
|
||||
@ -436,7 +436,7 @@ bool Bitmap::loadVBM(XFile *f) {
|
||||
f->seek(f->mark() + PAL_SIZ);
|
||||
}
|
||||
}
|
||||
if ((_v = farnew(uint8, n)) == NULL)
|
||||
if ((_v = new uint8[n]) == NULL)
|
||||
return false;
|
||||
|
||||
if (f->_error == 0)
|
||||
|
@ -136,6 +136,8 @@ CGEEngine::~CGEEngine() {
|
||||
delete _console;
|
||||
|
||||
// Delete engine objects
|
||||
delete _vga;
|
||||
delete _sys;
|
||||
delete _sprite;
|
||||
delete _miniCave;
|
||||
delete _shadow;
|
||||
@ -153,8 +155,6 @@ CGEEngine::~CGEEngine() {
|
||||
delete _snail;
|
||||
delete _snail_;
|
||||
delete _hero;
|
||||
delete _vga;
|
||||
delete _sys;
|
||||
}
|
||||
|
||||
Common::Error CGEEngine::run() {
|
||||
|
@ -154,7 +154,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0)
|
||||
_buttons = 0;
|
||||
_busy = NULL;
|
||||
_active = false;
|
||||
_flags._kill = true;
|
||||
_flags._kill = false;
|
||||
setSeq(ms);
|
||||
|
||||
BMP_PTR *MC = new BMP_PTR[3];
|
||||
|
@ -356,12 +356,14 @@ Sprite::Sprite(CGEEngine *vm, BMP_PTR *shpP)
|
||||
_seqPtr = 0;
|
||||
_shpCnt = 0;
|
||||
_prev = _next = NULL;
|
||||
|
||||
static int ctr = 1;
|
||||
debug("create %d %x", ctr++, this);
|
||||
setShapeList(shpP);
|
||||
}
|
||||
|
||||
|
||||
Sprite::~Sprite() {
|
||||
debug("destroy %x", this);
|
||||
if (_sprite == this)
|
||||
_sprite = NULL;
|
||||
contract();
|
||||
@ -775,7 +777,7 @@ BMP_PTR Sprite::ghost() {
|
||||
error("No core");
|
||||
bmp->_w = e->_b1->_w;
|
||||
bmp->_h = e->_b1->_h;
|
||||
if ((bmp->_b = farnew(HideDesc, bmp->_h)) == NULL)
|
||||
if ((bmp->_b = new HideDesc[bmp->_h]) == NULL)
|
||||
error("No Core");
|
||||
bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h);
|
||||
// TODO offset correctly in the surface using y1 pitch and x1 and not via offset segment
|
||||
@ -903,8 +905,18 @@ void Queue::insert(Sprite *spr) {
|
||||
spr->contract();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool contains(const Common::List<T> &l, const T &v) {
|
||||
return (Common::find(l.begin(), l.end(), v) != l.end());
|
||||
}
|
||||
Common::List<Sprite *> l;
|
||||
|
||||
Sprite *Queue::remove(Sprite *spr) {
|
||||
if (contains(l, spr)) {
|
||||
debug("N");
|
||||
}
|
||||
l.push_back(spr);
|
||||
|
||||
if (spr == _head)
|
||||
_head = spr->_next;
|
||||
if (spr == _tail)
|
||||
|
Loading…
Reference in New Issue
Block a user