From 7cac482a73917e4cfc00a9288d2fb72756353271 Mon Sep 17 00:00:00 2001 From: tron Date: Sat, 5 Feb 2005 18:05:42 +0000 Subject: (svn r1805) Teach the driver layer a few things about const correctness --- dedicated.c | 6 ++++-- extmidi.c | 2 +- hal.h | 14 +++++++------- os/beos/bemidi.cpp | 2 +- os2.c | 2 +- sdl.c | 12 ++++++------ ttd.c | 21 +++++++++++---------- w32dm.c | 4 ++-- win32.c | 6 +++--- 9 files changed, 36 insertions(+), 33 deletions(-) diff --git a/dedicated.c b/dedicated.c index 9ee6f4da1..608b0f429 100644 --- a/dedicated.c +++ b/dedicated.c @@ -128,7 +128,8 @@ void CloseWindowsConsoleThread(void) #endif -static const char *DedicatedVideoStart(char **parm) { +static const char *DedicatedVideoStart(const char * const *parm) +{ _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); @@ -306,7 +307,8 @@ const HalVideoDriver _dedicated_video_driver = { static void *_dedicated_video_mem; -static const char *DedicatedVideoStart(char **parm) { +static const char *DedicatedVideoStart(const char **parm) +{ DEBUG(misc,0)("OpenTTD compiled without network-support, quiting..."); return NULL; diff --git a/extmidi.c b/extmidi.c index f8e93b195..a03d4cf48 100644 --- a/extmidi.c +++ b/extmidi.c @@ -26,7 +26,7 @@ static void extmidi_kill(void) _pid = 0; } -static char *extmidi_start(char **parm) +static const char *extmidi_start(const char * const *parm) { _pid = 0; return NULL; diff --git a/hal.h b/hal.h index 3d7c34f0a..21b7d12cf 100644 --- a/hal.h +++ b/hal.h @@ -2,12 +2,12 @@ #define HAL_H typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); } HalCommonDriver; typedef struct { - const char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); void (*make_dirty)(int left, int top, int width, int height); int (*main_loop)(void); @@ -20,12 +20,12 @@ enum { }; typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); } HalSoundDriver; typedef struct { - char *(*start)(char **parm); + const char *(*start)(const char * const *parm); void (*stop)(void); void (*play_song)(const char *filename); @@ -88,9 +88,9 @@ extern bool _dbg_screen_rect; void LoadDriver(int driver, const char *name); -char *GetDriverParam(char **parm, const char *name); -bool GetDriverParamBool(char **parm, const char *name); -int GetDriverParamInt(char **parm, const char *name, int def); +const char *GetDriverParam(const char * const *parm, const char *name); +bool GetDriverParamBool(const char * const *parm, const char *name); +int GetDriverParamInt(const char * const *parm, const char *name, int def); diff --git a/os/beos/bemidi.cpp b/os/beos/bemidi.cpp index d0f41d865..969231a6d 100644 --- a/os/beos/bemidi.cpp +++ b/os/beos/bemidi.cpp @@ -9,7 +9,7 @@ BMidiSynthFile midiSynthFile; -static char *bemidi_start(char **parm) +static const char *bemidi_start(const char * const *parm) { return NULL; } diff --git a/os2.c b/os2.c index c426d28fc..858213866 100644 --- a/os2.c +++ b/os2.c @@ -656,7 +656,7 @@ static bool OS2MidiIsSongPlaying() return strcmp(buf, "playing") == 0 || strcmp(buf, "seeking") == 0; } -static char *OS2MidiStart(char **parm) +static const char *OS2MidiStart(const char * const *parm) { return 0; } diff --git a/sdl.c b/sdl.c index c5a7f7cf0..ba88af96d 100644 --- a/sdl.c +++ b/sdl.c @@ -103,7 +103,7 @@ static const char sdl_files[] = static SDLProcs _proc; -static char *LoadSdlDLL(void) +static const char *LoadSdlDLL(void) { if (_proc.SDL_Init != NULL) return NULL; @@ -138,11 +138,11 @@ static void SdlAbort(int sig) #endif -static char *SdlOpen(uint32 x) +static const char *SdlOpen(uint32 x) { #if defined(DYNAMICALLY_LOADED_SDL) && defined(WIN32) { - char *s = LoadSdlDLL(); + const char *s = LoadSdlDLL(); if (s != NULL) return s; } #endif @@ -540,7 +540,7 @@ static int PollEvent(void) return -1; } -static const char *SdlVideoStart(char **parm) +static const char *SdlVideoStart(const char * const *parm) { char buf[30]; @@ -654,11 +654,11 @@ static void CDECL fill_sound_buffer(void *userdata, Uint8 *stream, int len) MxMixSamples(_mixer, stream, len / 4); } -static char *SdlSoundStart(char **parm) +static const char *SdlSoundStart(const char * const *parm) { SDL_AudioSpec spec; - char *s = SdlOpen(SDL_INIT_AUDIO); + const char *s = SdlOpen(SDL_INIT_AUDIO); if (s != NULL) return s; spec.freq = GetDriverParamInt(parm, "hz", 11025); diff --git a/ttd.c b/ttd.c index f26e4d896..7dbf115e4 100644 --- a/ttd.c +++ b/ttd.c @@ -100,7 +100,7 @@ char * CDECL str_fmt(const char *str, ...) // NULL midi driver -static char *NullMidiStart(char **parm) { return NULL; } +static const char *NullMidiStart(const char * const *parm) { return NULL; } static void NullMidiStop(void) {} static void NullMidiPlaySong(const char *filename) {} static void NullMidiStopSong(void) {} @@ -118,7 +118,8 @@ const HalMusicDriver _null_music_driver = { // NULL video driver static void *_null_video_mem; -static const char *NullVideoStart(char **parm) { +static const char *NullVideoStart(const char * const *parm) +{ _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; _null_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); @@ -149,7 +150,7 @@ const HalVideoDriver _null_video_driver = { }; // NULL sound driver -static char *NullSoundStart(char **parm) { return NULL; } +static const char *NullSoundStart(const char * const *parm) { return NULL; } static void NullSoundStop(void) {} const HalSoundDriver _null_sound_driver = { NullSoundStart, @@ -254,7 +255,7 @@ void LoadDriver(int driver, const char *name) const char *err; char *parm; char buffer[256]; - char *parms[32]; + const char *parms[32]; parms[0] = NULL; @@ -330,9 +331,9 @@ static void showhelp(void) } -char *GetDriverParam(char **parm, const char *name) +const char *GetDriverParam(const char * const *parm, const char *name) { - char *p; + const char *p; int len = strlen(name); while ((p = *parm++) != NULL) { if (!strncmp(p,name,len)) { @@ -343,15 +344,15 @@ char *GetDriverParam(char **parm, const char *name) return NULL; } -bool GetDriverParamBool(char **parm, const char *name) +bool GetDriverParamBool(const char * const *parm, const char *name) { - char *p = GetDriverParam(parm, name); + const char *p = GetDriverParam(parm, name); return p != NULL; } -int GetDriverParamInt(char **parm, const char *name, int def) +int GetDriverParamInt(const char * const *parm, const char *name, int def) { - char *p = GetDriverParam(parm, name); + const char *p = GetDriverParam(parm, name); return p != NULL ? atoi(p) : def; } diff --git a/w32dm.c b/w32dm.c index 149266994..89617c2c6 100644 --- a/w32dm.c +++ b/w32dm.c @@ -32,7 +32,7 @@ #include "sound.h" #include "hal.h" -static char * DMusicMidiStart(char **parm); +static const char * DMusicMidiStart(const char * const *parm); static void DMusicMidiStop(void); static void DMusicMidiPlaySong(const char *filename); static void DMusicMidiStopSong(void); @@ -60,7 +60,7 @@ extern void SetVolume (long); bool seeking = false; -static char * DMusicMidiStart(char **parm) +static const char * DMusicMidiStart(const char * const *parm) { if (InitDirectMusic() == true) return(0); diff --git a/win32.c b/win32.c index 022472766..c387e58c4 100644 --- a/win32.c +++ b/win32.c @@ -606,7 +606,7 @@ static void FindResolutions(void) } -static const char *Win32GdiStart(char **parm) +static const char *Win32GdiStart(const char * const *parm) { memset(&_wnd, 0, sizeof(_wnd)); _wnd.cursor_visible = true; @@ -879,7 +879,7 @@ static DWORD WINAPI MidiThread(LPVOID arg) return 0; } -static char *Win32MidiStart(char **parm) +static const char *Win32MidiStart(const char * const *parm) { DWORD threadId; memset(&_midi, 0, sizeof(_midi)); @@ -939,7 +939,7 @@ static void CALLBACK waveOutProc(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance, DWOR } } -static char *Win32SoundStart(char **parm) +static const char *Win32SoundStart(const char * const *parm) { WAVEFORMATEX wfex; int hz; -- cgit v1.2.3-70-g09d2