simplify SetDSerror
- no need to keep the error in a static variable - always print the error code - reduce the required stack-size - reduce the number of snprintf calls (and code size)main
parent
01663238dc
commit
01bfde4520
|
@ -98,10 +98,8 @@ DSOUND_Load(void)
|
||||||
static int
|
static int
|
||||||
SetDSerror(const char *function, int code)
|
SetDSerror(const char *function, int code)
|
||||||
{
|
{
|
||||||
static const char *error;
|
const char *error;
|
||||||
static char errbuf[1024];
|
|
||||||
|
|
||||||
errbuf[0] = 0;
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case E_NOINTERFACE:
|
case E_NOINTERFACE:
|
||||||
error = "Unsupported interface -- Is DirectX 8.0 or later installed?";
|
error = "Unsupported interface -- Is DirectX 8.0 or later installed?";
|
||||||
|
@ -137,15 +135,11 @@ SetDSerror(const char *function, int code)
|
||||||
error = "Function not supported";
|
error = "Function not supported";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SDL_snprintf(errbuf, SDL_arraysize(errbuf),
|
error = "Unknown DirectSound error";
|
||||||
"%s: Unknown DirectSound error: 0x%x", function, code);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!errbuf[0]) {
|
|
||||||
SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
|
return SDL_SetError("%s: %s (0x%x)", function, error, code);
|
||||||
error);
|
|
||||||
}
|
|
||||||
return SDL_SetError("%s", errbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue