diff --git a/src/common.h b/src/common.h index aacc011..84870aa 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,6 @@ #ifndef __cplusplus #define inline __inline #endif -#define strdup _strdup #define strcasecmp _stricmp #define snprintf _snprintf #define kbhit _kbhit @@ -77,6 +76,8 @@ int report(const char *, ...); void delay_ms(int msec); +char *xmp_strdup(const char *); + /* option */ void get_options(int, char **, struct options *); int read_config(struct options *); diff --git a/src/main.c b/src/main.c index e04187e..b2096bd 100644 --- a/src/main.c +++ b/src/main.c @@ -44,6 +44,15 @@ static struct sound_driver *sound; static unsigned int foreground_in, foreground_out; static int refresh_status; +char *xmp_strdup(const char *in) +{ + size_t len = strlen(in) + 1; + char *out = (char *) malloc(len); + if (out) { + memcpy(out, in, len); + } + return out; +} int report(const char *fmt, ...) { diff --git a/src/read_config.c b/src/read_config.c index e34d51c..796c118 100644 --- a/src/read_config.c +++ b/src/read_config.c @@ -164,7 +164,7 @@ int read_config(struct options *o) */ if (o->dparm < MAX_DRV_PARM) { snprintf(cparm, 512, "%s=%s", var, val); - o->driver_parm[o->dparm++] = strdup(cparm); + o->driver_parm[o->dparm++] = xmp_strdup(cparm); } } diff --git a/src/sound_file.c b/src/sound_file.c index 4e011fe..3fbc384 100644 --- a/src/sound_file.c +++ b/src/sound_file.c @@ -49,7 +49,7 @@ static int init(struct options *options) options->out_file); sound_file.description = buf; } else { - sound_file.description = strdup("stdout"); + sound_file.description = xmp_strdup("stdout"); } return 0; diff --git a/src/sound_wav.c b/src/sound_wav.c index f495d32..117dde9 100644 --- a/src/sound_wav.c +++ b/src/sound_wav.c @@ -76,7 +76,7 @@ static int init(struct options *options) options->out_file); sound_wav.description = buf; } else { - sound_wav.description = strdup("WAV writer: stdout"); + sound_wav.description = xmp_strdup("WAV writer: stdout"); len = -1; }