invent and use a private xmp_strdup()

master
Ozkan Sezer 4 years ago committed by Ozkan Sezer
parent 062473c1c5
commit bc7fa57fcc
  1. 3
      src/common.h
  2. 9
      src/main.c
  3. 2
      src/read_config.c
  4. 2
      src/sound_file.c
  5. 2
      src/sound_wav.c

@ -6,7 +6,6 @@
#ifndef __cplusplus #ifndef __cplusplus
#define inline __inline #define inline __inline
#endif #endif
#define strdup _strdup
#define strcasecmp _stricmp #define strcasecmp _stricmp
#define snprintf _snprintf #define snprintf _snprintf
#define kbhit _kbhit #define kbhit _kbhit
@ -77,6 +76,8 @@ int report(const char *, ...);
void delay_ms(int msec); void delay_ms(int msec);
char *xmp_strdup(const char *);
/* option */ /* option */
void get_options(int, char **, struct options *); void get_options(int, char **, struct options *);
int read_config(struct options *); int read_config(struct options *);

@ -44,6 +44,15 @@ static struct sound_driver *sound;
static unsigned int foreground_in, foreground_out; static unsigned int foreground_in, foreground_out;
static int refresh_status; 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, ...) int report(const char *fmt, ...)
{ {

@ -164,7 +164,7 @@ int read_config(struct options *o)
*/ */
if (o->dparm < MAX_DRV_PARM) { if (o->dparm < MAX_DRV_PARM) {
snprintf(cparm, 512, "%s=%s", var, val); snprintf(cparm, 512, "%s=%s", var, val);
o->driver_parm[o->dparm++] = strdup(cparm); o->driver_parm[o->dparm++] = xmp_strdup(cparm);
} }
} }

@ -49,7 +49,7 @@ static int init(struct options *options)
options->out_file); options->out_file);
sound_file.description = buf; sound_file.description = buf;
} else { } else {
sound_file.description = strdup("stdout"); sound_file.description = xmp_strdup("stdout");
} }
return 0; return 0;

@ -76,7 +76,7 @@ static int init(struct options *options)
options->out_file); options->out_file);
sound_wav.description = buf; sound_wav.description = buf;
} else { } else {
sound_wav.description = strdup("WAV writer: stdout"); sound_wav.description = xmp_strdup("WAV writer: stdout");
len = -1; len = -1;
} }

Loading…
Cancel
Save