diff --git a/source/lib/res/res.cpp b/source/lib/res/res.cpp index 816e03e22c..e1e853df36 100755 --- a/source/lib/res/res.cpp +++ b/source/lib/res/res.cpp @@ -46,7 +46,7 @@ int res_reload_changed_files() const char* fn = vfs_path; - char* ext = strrchr(fn, '.'); + const char* ext = strrchr(fn, '.'); // slight optimization (and reduces output clutter): // don't reload XMB output files diff --git a/source/lib/res/snd.cpp b/source/lib/res/snd.cpp index a003f5c526..966bbf9bd8 100755 --- a/source/lib/res/snd.cpp +++ b/source/lib/res/snd.cpp @@ -334,7 +334,7 @@ static int ALBuffer_reload(ALBuffer* b, const char* fn, Handle) ALenum al_format; ALsizei al_sample_rate; - char* ext = strrchr(fn, '.'); + const char* ext = strrchr(fn, '.'); // .. OGG (data will be passed directly to OpenAL) if(ext && !stricmp(ext, ".ogg")) { @@ -378,12 +378,14 @@ static int ALBuffer_reload(ALBuffer* b, const char* fn, Handle) ret = file_size; goto fail; } - void* file = malloc(file_size); // freed soon after + void* file = mem_alloc(file_size, 65536); // freed soon after if(!file) { ret = ERR_NO_MEM; goto fail; } +memset(file, 0xe2, file_size); + // read from file. note: don't use vfs_load - detect_audio_fmt // has seeked to the actual audio data in the file. @@ -399,7 +401,7 @@ static int ALBuffer_reload(ALBuffer* b, const char* fn, Handle) ret = 0; fail: - free(file); + mem_free(file); vfs_close(hf); } @@ -672,8 +674,8 @@ static int Sound_reload(Sound* s, const char* fn, Handle hs) CHECK_ERR(vfs_stat(fn, &stat_buf)); off_t file_size = stat_buf.st_size; // big enough to warrant streaming - if(file_size > CLIP_MAX_SIZE) - s->flags = SF_STREAMING; +// if(file_size > CLIP_MAX_SIZE) +// s->flags = SF_STREAMING; // TODO: let caller decide as well @@ -702,7 +704,7 @@ static int Sound_reload(Sound* s, const char* fn, Handle hs) } -// open and return a handle to the sound clip . +// open and return a handle to the sound . Handle sound_open(const char* const fn) { snd_init(); diff --git a/source/lib/res/tex.cpp b/source/lib/res/tex.cpp index ea7a992d4c..b9968cc9d4 100755 --- a/source/lib/res/tex.cpp +++ b/source/lib/res/tex.cpp @@ -1128,7 +1128,7 @@ int tex_write(const char* fn, int w, int h, int bpp, int flags, void* img) { const size_t img_size = w * h * bpp / 8; - char* ext = strrchr(fn, '.'); + const char* ext = strrchr(fn, '.'); if(!ext) return -1; diff --git a/source/lib/res/vfs.cpp b/source/lib/res/vfs.cpp index 2531fa5a28..4f55365e1a 100755 --- a/source/lib/res/vfs.cpp +++ b/source/lib/res/vfs.cpp @@ -469,7 +469,7 @@ static int tree_lookup(const char* _c_path, const Loc** const loc = 0, Dir** con for(;;) { // "extract" cur_component string (0-terminate by replacing '/') - char* slash = strchr(cur_component, '/'); + const char* slash = strchr(cur_component, '/'); if(slash) *slash = 0; @@ -1090,7 +1090,7 @@ int vfs_next_dirent(const Handle hd, vfsDirEnt* ent, const char* const filter) fn = vd->file_it->first.c_str(); ++vd->file_it; - char* const ext = strrchr(fn, '.'); + const char* ext = strrchr(fn, '.'); // file has an extension if(ext) {