diff --git a/src/AV.cc b/src/AV.cc index 75b91e8..9fc30d0 100644 --- a/src/AV.cc +++ b/src/AV.cc @@ -259,7 +259,7 @@ AV::Sound::~Sound() } } -bool AV::Sound::load(unsigned char *data, unsigned int size) +bool AV::Sound::load(const unsigned char *data, unsigned int size) { m_data = new unsigned char[size]; memcpy(m_data, data, size); diff --git a/src/AV.h b/src/AV.h index cc0a80e..b3c45d7 100644 --- a/src/AV.h +++ b/src/AV.h @@ -27,7 +27,7 @@ class AV public: Sound(AV & av); ~Sound(); - bool load(unsigned char *data, unsigned int size); + bool load(const unsigned char *data, unsigned int size); void play(); void resume(); void stop(); diff --git a/src/Engine.cc b/src/Engine.cc index 6c7d59e..3f6049f 100644 --- a/src/Engine.cc +++ b/src/Engine.cc @@ -636,11 +636,11 @@ int Engine::loadSound(const string & name) refptr avs = m_av.createSound(); unsigned int size; - unsigned char *data = loadFile(nm.c_str(), &size); + const unsigned char *data = loadFile(nm.c_str(), &size); if (data != NULL) { bool loaded = avs->load(data, size); - free(data); + delete[] data; if (loaded) return addSound(avs); } @@ -1283,7 +1283,7 @@ const unsigned char *Engine::loadFile(const char *fname, unsigned int *len) FILE * fp = fopen(file_path.c_str(), "rb"); if (fp != NULL) { - unsigned char *data = malloc(size); + unsigned char *data = new unsigned char[size]; int num_read = fread(data, size, 1, fp); fclose(fp); if (num_read > 0)