fix some qualifiers dealing with loadFile()

This commit is contained in:
Josh Holtrop 2011-05-21 23:42:52 -04:00
parent 15c30e0d00
commit 07f4162581
3 changed files with 5 additions and 5 deletions

View File

@ -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]; m_data = new unsigned char[size];
memcpy(m_data, data, size); memcpy(m_data, data, size);

View File

@ -27,7 +27,7 @@ class AV
public: public:
Sound(AV & av); Sound(AV & av);
~Sound(); ~Sound();
bool load(unsigned char *data, unsigned int size); bool load(const unsigned char *data, unsigned int size);
void play(); void play();
void resume(); void resume();
void stop(); void stop();

View File

@ -636,11 +636,11 @@ int Engine::loadSound(const string & name)
refptr<AV::Sound> avs = m_av.createSound(); refptr<AV::Sound> avs = m_av.createSound();
unsigned int size; unsigned int size;
unsigned char *data = loadFile(nm.c_str(), &size); const unsigned char *data = loadFile(nm.c_str(), &size);
if (data != NULL) if (data != NULL)
{ {
bool loaded = avs->load(data, size); bool loaded = avs->load(data, size);
free(data); delete[] data;
if (loaded) if (loaded)
return addSound(avs); 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"); FILE * fp = fopen(file_path.c_str(), "rb");
if (fp != NULL) if (fp != NULL)
{ {
unsigned char *data = malloc(size); unsigned char *data = new unsigned char[size];
int num_read = fread(data, size, 1, fp); int num_read = fread(data, size, 1, fp);
fclose(fp); fclose(fp);
if (num_read > 0) if (num_read > 0)