ini: Constify parameters to optimize execution
This commit is contained in:
@@ -719,7 +719,7 @@ load_sound(void)
|
|||||||
mpu401_standalone_enable = !!ini_section_get_int(cat, "mpu401_standalone", 0);
|
mpu401_standalone_enable = !!ini_section_get_int(cat, "mpu401_standalone", 0);
|
||||||
|
|
||||||
/* Backwards compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
/* Backwards compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
||||||
char *legacy_cards[][2] = {{"ssi2001", "ssi2001"}, {"gameblaster", "cms"}, {"gus", "gus"}};
|
const char *legacy_cards[][2] = {{"ssi2001", "ssi2001"}, {"gameblaster", "cms"}, {"gus", "gus"}};
|
||||||
for (int i = 0, j = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
for (int i = 0, j = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||||
if (ini_section_get_int(cat, legacy_cards[i][0], 0) == 1) {
|
if (ini_section_get_int(cat, legacy_cards[i][0], 0) == 1) {
|
||||||
/* Migrate to the first available sound card slot. */
|
/* Migrate to the first available sound card slot. */
|
||||||
@@ -2405,7 +2405,7 @@ save_sound(void)
|
|||||||
ini_section_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
ini_section_set_int(cat, "mpu401_standalone", mpu401_standalone_enable);
|
||||||
|
|
||||||
/* Downgrade compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
/* Downgrade compatibility for standalone SSI-2001, CMS and GUS from v3.11 and older. */
|
||||||
char *legacy_cards[][2] = {{"ssi2001", "ssi2001"}, {"gameblaster", "cms"}, {"gus", "gus"}};
|
const char *legacy_cards[][2] = {{"ssi2001", "ssi2001"}, {"gameblaster", "cms"}, {"gus", "gus"}};
|
||||||
for (int i = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
for (int i = 0; i < (sizeof(legacy_cards) / sizeof(legacy_cards[0])); i++) {
|
||||||
int card_id = sound_card_get_from_internal_name(legacy_cards[i][1]);
|
int card_id = sound_card_get_from_internal_name(legacy_cards[i][1]);
|
||||||
for (int j = 0; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
|
for (int j = 0; j < (sizeof(sound_card_current) / sizeof(sound_card_current[0])); j++) {
|
||||||
|
@@ -30,26 +30,26 @@ typedef void *ini_t;
|
|||||||
typedef void *ini_section_t;
|
typedef void *ini_section_t;
|
||||||
|
|
||||||
extern ini_t ini_new(void);
|
extern ini_t ini_new(void);
|
||||||
extern ini_t ini_read(char *fn);
|
extern ini_t ini_read(const char *fn);
|
||||||
extern void ini_write(ini_t ini, char *fn);
|
extern void ini_write(ini_t ini, const char *fn);
|
||||||
extern void ini_dump(ini_t ini);
|
extern void ini_dump(ini_t ini);
|
||||||
extern void ini_close(ini_t ini);
|
extern void ini_close(ini_t ini);
|
||||||
|
|
||||||
extern void ini_section_delete_var(ini_section_t section, char *name);
|
extern void ini_section_delete_var(ini_section_t section, const char *name);
|
||||||
extern int ini_section_get_int(ini_section_t section, char *name, int def);
|
extern int ini_section_get_int(ini_section_t section, const char *name, int def);
|
||||||
extern double ini_section_get_double(ini_section_t section, char *name, double def);
|
extern double ini_section_get_double(ini_section_t section, const char *name, double def);
|
||||||
extern int ini_section_get_hex16(ini_section_t section, char *name, int def);
|
extern int ini_section_get_hex16(ini_section_t section, const char *name, int def);
|
||||||
extern int ini_section_get_hex20(ini_section_t section, char *name, int def);
|
extern int ini_section_get_hex20(ini_section_t section, const char *name, int def);
|
||||||
extern int ini_section_get_mac(ini_section_t section, char *name, int def);
|
extern int ini_section_get_mac(ini_section_t section, const char *name, int def);
|
||||||
extern char *ini_section_get_string(ini_section_t section, char *name, char *def);
|
extern char *ini_section_get_string(ini_section_t section, const char *name, char *def);
|
||||||
extern wchar_t *ini_section_get_wstring(ini_section_t section, char *name, wchar_t *def);
|
extern wchar_t *ini_section_get_wstring(ini_section_t section, const char *name, wchar_t *def);
|
||||||
extern void ini_section_set_int(ini_section_t section, char *name, int val);
|
extern void ini_section_set_int(ini_section_t section, const char *name, int val);
|
||||||
extern void ini_section_set_double(ini_section_t section, char *name, double val);
|
extern void ini_section_set_double(ini_section_t section, const char *name, double val);
|
||||||
extern void ini_section_set_hex16(ini_section_t section, char *name, int val);
|
extern void ini_section_set_hex16(ini_section_t section, const char *name, int val);
|
||||||
extern void ini_section_set_hex20(ini_section_t section, char *name, int val);
|
extern void ini_section_set_hex20(ini_section_t section, const char *name, int val);
|
||||||
extern void ini_section_set_mac(ini_section_t section, char *name, int val);
|
extern void ini_section_set_mac(ini_section_t section, const char *name, int val);
|
||||||
extern void ini_section_set_string(ini_section_t section, const char *name, const char *val);
|
extern void ini_section_set_string(ini_section_t section, const char *name, const char *val);
|
||||||
extern void ini_section_set_wstring(ini_section_t section, char *name, wchar_t *val);
|
extern void ini_section_set_wstring(ini_section_t section, const char *name, wchar_t *val);
|
||||||
|
|
||||||
#define ini_delete_var(ini, head, name) ini_section_delete_var(ini_find_section(ini, head), name)
|
#define ini_delete_var(ini, head, name) ini_section_delete_var(ini_find_section(ini, head), name)
|
||||||
|
|
||||||
@@ -69,13 +69,13 @@ extern void ini_section_set_wstring(ini_section_t section, char *name, wchar
|
|||||||
#define ini_set_string(ini, head, name, val) ini_section_set_string(ini_find_or_create_section(ini, head), name, val)
|
#define ini_set_string(ini, head, name, val) ini_section_set_string(ini_find_or_create_section(ini, head), name, val)
|
||||||
#define ini_set_wstring(ini, head, name, val) ini_section_set_wstring(ini_find_or_create_section(ini, head), name, val)
|
#define ini_set_wstring(ini, head, name, val) ini_section_set_wstring(ini_find_or_create_section(ini, head), name, val)
|
||||||
|
|
||||||
extern ini_section_t ini_find_section(ini_t ini, char *name);
|
extern ini_section_t ini_find_section(ini_t ini, const char *name);
|
||||||
extern ini_section_t ini_find_or_create_section(ini_t ini, char *name);
|
extern ini_section_t ini_find_or_create_section(ini_t ini, const char *name);
|
||||||
extern void ini_rename_section(ini_section_t section, char *name);
|
extern void ini_rename_section(ini_section_t section, const char *name);
|
||||||
extern void ini_delete_section_if_empty(ini_t ini, ini_section_t section);
|
extern void ini_delete_section_if_empty(ini_t ini, ini_section_t section);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -62,7 +62,7 @@ extern const device_t *sound_card_getdevice(int card);
|
|||||||
#endif
|
#endif
|
||||||
extern int sound_card_has_config(int card);
|
extern int sound_card_has_config(int card);
|
||||||
extern char *sound_card_get_internal_name(int card);
|
extern char *sound_card_get_internal_name(int card);
|
||||||
extern int sound_card_get_from_internal_name(char *s);
|
extern int sound_card_get_from_internal_name(const char *s);
|
||||||
extern void sound_card_init(void);
|
extern void sound_card_init(void);
|
||||||
extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r);
|
extern void sound_set_cd_volume(unsigned int vol_l, unsigned int vol_r);
|
||||||
|
|
||||||
|
46
src/ini.c
46
src/ini.c
@@ -101,10 +101,10 @@ ini_log(const char *fmt, ...)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static section_t *
|
static section_t *
|
||||||
find_section(list_t *head, char *name)
|
find_section(list_t *head, const char *name)
|
||||||
{
|
{
|
||||||
section_t *sec = (section_t *) head->next;
|
section_t *sec = (section_t *) head->next;
|
||||||
char blank[] = "";
|
const char blank[] = "";
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
name = blank;
|
name = blank;
|
||||||
@@ -120,7 +120,7 @@ find_section(list_t *head, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ini_section_t
|
ini_section_t
|
||||||
ini_find_section(ini_t ini, char *name)
|
ini_find_section(ini_t ini, const char *name)
|
||||||
{
|
{
|
||||||
if (ini == NULL)
|
if (ini == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -129,7 +129,7 @@ ini_find_section(ini_t ini, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_rename_section(ini_section_t section, char *name)
|
ini_rename_section(ini_section_t section, const char *name)
|
||||||
{
|
{
|
||||||
section_t *sec = (section_t *) section;
|
section_t *sec = (section_t *) section;
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ ini_delete_section_if_empty(ini_t ini, ini_section_t section)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static section_t *
|
static section_t *
|
||||||
create_section(list_t *head, char *name)
|
create_section(list_t *head, const char *name)
|
||||||
{
|
{
|
||||||
section_t *ns = malloc(sizeof(section_t));
|
section_t *ns = malloc(sizeof(section_t));
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ create_section(list_t *head, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ini_section_t
|
ini_section_t
|
||||||
ini_find_or_create_section(ini_t ini, char *name)
|
ini_find_or_create_section(ini_t ini, const char *name)
|
||||||
{
|
{
|
||||||
if (ini == NULL)
|
if (ini == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -263,7 +263,7 @@ ini_close(ini_t ini)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ini_detect_bom(char *fn)
|
ini_detect_bom(const char *fn)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
unsigned char bom[4] = { 0, 0, 0, 0 };
|
unsigned char bom[4] = { 0, 0, 0, 0 };
|
||||||
@@ -311,7 +311,7 @@ ini_fgetws(wchar_t *str, int count, FILE *stream)
|
|||||||
|
|
||||||
/* Read and parse the configuration file into memory. */
|
/* Read and parse the configuration file into memory. */
|
||||||
ini_t
|
ini_t
|
||||||
ini_read(char *fn)
|
ini_read(const char *fn)
|
||||||
{
|
{
|
||||||
char sname[128], ename[128];
|
char sname[128], ename[128];
|
||||||
wchar_t buff[1024];
|
wchar_t buff[1024];
|
||||||
@@ -438,7 +438,7 @@ ini_read(char *fn)
|
|||||||
|
|
||||||
/* Write the in-memory configuration to disk. */
|
/* Write the in-memory configuration to disk. */
|
||||||
void
|
void
|
||||||
ini_write(ini_t ini, char *fn)
|
ini_write(ini_t ini, const char *fn)
|
||||||
{
|
{
|
||||||
wchar_t wtemp[512];
|
wchar_t wtemp[512];
|
||||||
list_t *list = (list_t *) ini;
|
list_t *list = (list_t *) ini;
|
||||||
@@ -521,7 +521,7 @@ ini_dump(ini_t ini)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_delete_var(ini_section_t self, char *name)
|
ini_section_delete_var(ini_section_t self, const char *name)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -537,7 +537,7 @@ ini_section_delete_var(ini_section_t self, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ini_section_get_int(ini_section_t self, char *name, int def)
|
ini_section_get_int(ini_section_t self, const char *name, int def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -556,7 +556,7 @@ ini_section_get_int(ini_section_t self, char *name, int def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
ini_section_get_double(ini_section_t self, char *name, double def)
|
ini_section_get_double(ini_section_t self, const char *name, double def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -575,7 +575,7 @@ ini_section_get_double(ini_section_t self, char *name, double def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ini_section_get_hex16(ini_section_t self, char *name, int def)
|
ini_section_get_hex16(ini_section_t self, const char *name, int def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -594,7 +594,7 @@ ini_section_get_hex16(ini_section_t self, char *name, int def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ini_section_get_hex20(ini_section_t self, char *name, int def)
|
ini_section_get_hex20(ini_section_t self, const char *name, int def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -613,7 +613,7 @@ ini_section_get_hex20(ini_section_t self, char *name, int def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ini_section_get_mac(ini_section_t self, char *name, int def)
|
ini_section_get_mac(ini_section_t self, const char *name, int def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -632,7 +632,7 @@ ini_section_get_mac(ini_section_t self, char *name, int def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ini_section_get_string(ini_section_t self, char *name, char *def)
|
ini_section_get_string(ini_section_t self, const char *name, char *def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -648,7 +648,7 @@ ini_section_get_string(ini_section_t self, char *name, char *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *
|
wchar_t *
|
||||||
ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
|
ini_section_get_wstring(ini_section_t self, const char *name, wchar_t *def)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
@@ -664,7 +664,7 @@ ini_section_get_wstring(ini_section_t self, char *name, wchar_t *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_int(ini_section_t self, char *name, int val)
|
ini_section_set_int(ini_section_t self, const char *name, int val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
@@ -681,7 +681,7 @@ ini_section_set_int(ini_section_t self, char *name, int val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_double(ini_section_t self, char *name, double val)
|
ini_section_set_double(ini_section_t self, const char *name, double val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
@@ -698,7 +698,7 @@ ini_section_set_double(ini_section_t self, char *name, double val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_hex16(ini_section_t self, char *name, int val)
|
ini_section_set_hex16(ini_section_t self, const char *name, int val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
@@ -715,7 +715,7 @@ ini_section_set_hex16(ini_section_t self, char *name, int val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_hex20(ini_section_t self, char *name, int val)
|
ini_section_set_hex20(ini_section_t self, const char *name, int val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
@@ -732,7 +732,7 @@ ini_section_set_hex20(ini_section_t self, char *name, int val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_mac(ini_section_t self, char *name, int val)
|
ini_section_set_mac(ini_section_t self, const char *name, int val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
@@ -774,7 +774,7 @@ ini_section_set_string(ini_section_t self, const char *name, const char *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ini_section_set_wstring(ini_section_t self, char *name, wchar_t *val)
|
ini_section_set_wstring(ini_section_t self, const char *name, wchar_t *val)
|
||||||
{
|
{
|
||||||
section_t *section = (section_t *) self;
|
section_t *section = (section_t *) self;
|
||||||
entry_t *ent;
|
entry_t *ent;
|
||||||
|
@@ -202,7 +202,7 @@ sound_card_get_internal_name(int card)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
sound_card_get_from_internal_name(char *s)
|
sound_card_get_from_internal_name(const char *s)
|
||||||
{
|
{
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user