author | ecalot
<ecalot> 2006-07-15 06:56:41 UTC |
committer | ecalot
<ecalot> 2006-07-15 06:56:41 UTC |
parent | d5b4077ce80e143b20a092a2cf55069582d73d11 |
PR/src/lib/formats/pal.c | +1 | -1 |
PR/src/lib/formats/wav.c | +3 | -0 |
PR/src/lib/object/object.c | +2 | -1 |
PR/src/lib/object/palette/pop1_16c.c | +2 | -0 |
PR/src/lib/object/sound/sound_common.c | +3 | -1 |
diff --git a/PR/src/lib/formats/pal.c b/PR/src/lib/formats/pal.c index eece13b..a5f1d69 100644 --- a/PR/src/lib/formats/pal.c +++ b/PR/src/lib/formats/pal.c @@ -93,7 +93,7 @@ int readPal(const char* file,tColor* *colorArray,int *colors) { fclose(fd); if (!ok) { free(*colorArray); - return -40; + return -40; /* TODO: assign code for wrong jasc pal format */ } return PR_RESULT_SUCCESS; diff --git a/PR/src/lib/formats/wav.c b/PR/src/lib/formats/wav.c index b189670..673c064 100644 --- a/PR/src/lib/formats/wav.c +++ b/PR/src/lib/formats/wav.c @@ -76,6 +76,8 @@ int readWav(const char* file, tBinary* snd, int *pchannels, long *psamplerate, l short int BitsPerSample; long int SubChunk2Size=0; + snd->isCopy=1; + fd=fopen(file,"rb"); if (!fd) return PR_RESULT_ERR_FILE_NOT_READ_ACCESS; @@ -110,6 +112,7 @@ int readWav(const char* file, tBinary* snd, int *pchannels, long *psamplerate, l if (ok) { snd->size=SubChunk2Size; snd->data=malloc(SubChunk2Size); + snd->isCopy=0; ok=fread(snd->data,SubChunk2Size,1,fd); fclose(fd); } else { diff --git a/PR/src/lib/object/object.c b/PR/src/lib/object/object.c index 4f5aeb0..ac17f7b 100644 --- a/PR/src/lib/object/object.c +++ b/PR/src/lib/object/object.c @@ -226,9 +226,10 @@ tObject objectRead(const char* file,tResource* res,int *result) { switch (res->type) { case eResTypeLevelPop1: /*o.obj=objectLevelPop1Read(file,res.content,result); TODO */ + *result=-1; /* TODO: unsupported object */ break; case eResTypeImage16: - o.obj=objectImage16Read(file,*res->palette,result); + o.obj=objectImage16Read(file,*res->palette /*TODO: check because sometimes it is not initialized */,result); break; case eResTypeSoundWave: o.obj=objectSoundWaveRead(file,result); diff --git a/PR/src/lib/object/palette/pop1_16c.c b/PR/src/lib/object/palette/pop1_16c.c index b6e5f9b..248bebf 100644 --- a/PR/src/lib/object/palette/pop1_16c.c +++ b/PR/src/lib/object/palette/pop1_16c.c @@ -138,6 +138,8 @@ void* objectPalettePop1_16Read(const char* file,int *result) { char aux[260]; tBinary raw; + *result=PR_RESULT_ERR_FILE_NOT_OPEN_NOTFOUND; + /* Import extra palette information */ sprintf(aux,"%s.more",file); raw=mLoadFileArray(aux); diff --git a/PR/src/lib/object/sound/sound_common.c b/PR/src/lib/object/sound/sound_common.c index bac2090..1a8c50a 100644 --- a/PR/src/lib/object/sound/sound_common.c +++ b/PR/src/lib/object/sound/sound_common.c @@ -86,8 +86,10 @@ void* objectSoundWaveRead(const char* file, int *result) { if (samplerate!=11025) *result=PR_RESULT_WAV_UNSUPPORTED_SAMPLERATE; if (channels!=1) *result=PR_RESULT_WAV_UNSUPPORTED_STEREO; } + if (*result!=PR_RESULT_SUCCESS) { - free(o->data); + if (!o->isCopy) free(o->data); + free(o); return NULL; }