1
0
forked from 0ad/0ad

VC2k5 fix: strchr return value saved as const char* (cf Stu's CVS report #161)

This was SVN commit r1183.
This commit is contained in:
janwas 2004-09-21 18:43:58 +00:00
parent ff4af72da1
commit 0868b2ee6c
4 changed files with 12 additions and 10 deletions

View File

@ -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

View File

@ -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 <fn>.
// open and return a handle to the sound <fn>.
Handle sound_open(const char* const fn)
{
snd_init();

View File

@ -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;

View File

@ -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)
{