Skip to content

Commit 336aa41

Browse files
committed
fix a few more static variable problems in Timidity++
* rcf_count in Instruments::read_config_file * sbk_convertors shoukd be const * Instruments::chunkid.idstring should be const - also reduced memory usage by using char array instead of char *. * Instruments::get_importers.get_importers: sample_importers cannot be statically initialized so make it a non-static local variable instead.
1 parent 2f880ef commit 336aa41

File tree

9 files changed

+9
-8
lines changed

9 files changed

+9
-8
lines changed

thirdparty/timidity/timidity.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ int Instruments::read_config_file(const char *name)
182182
char tmp[1024], *cp;
183183
ToneBank *bank = NULL;
184184
int i, j, k, line = 0, words;
185-
static int rcf_count = 0;
186185

187186
if (rcf_count > 50)
188187
{

thirdparty/timidity/timidity/instrum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class Instruments
172172
ToneBank* drumset[MAXBANK] = {};
173173
FontFile* Fonts = nullptr;
174174
std::string def_instr_name;
175+
int rcf_count = 0;
175176

176177
Instruments(MusicIO::SoundFontReaderInterface* reader);
177178
~Instruments();

thirdparty/timidityplus/configfile.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ int Instruments::read_config_file(const char *name, int self, int allow_missing_
619619
char buf[1024], *tmp, *w[MAXWORDS + 1], *cp;
620620
ToneBank *bank = NULL;
621621
int i, j, k, line = 0, words, errcnt = 0;
622-
static int rcf_count = 0;
623622
int dr = 0, bankno = 0, mapid = INST_NO_MAP, origbankno = 0x7FFFFFFF;
624623
int extension_flag, param_parse_err;
625624
MBlockList varbuf;

thirdparty/timidityplus/instrum.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,6 @@ int Instruments::set_default_instrument(char *name)
15651565
{
15661566
Instrument *ip;
15671567
int i;
1568-
static char *last_name;
15691568

15701569
if (name == NULL)
15711570
{

thirdparty/timidityplus/resample.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int sample_bounds_min, sample_bounds_max; /* min/max bounds for sample da
4444
#define DEFAULT_GAUSS_ORDER 25
4545
std::vector<float> gauss_table_data;
4646
static float *gauss_table[(1 << FRACTION_BITS)] = { 0 }; /* don't need doubles */
47-
static int gauss_n = DEFAULT_GAUSS_ORDER;
47+
static const int gauss_n = DEFAULT_GAUSS_ORDER;
4848

4949

5050
static void initialize_newton_coeffs()

thirdparty/timidityplus/sbkconv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int sbk_modsust(int gen, int val);
7070
* convertor function table
7171
*----------------------------------------------------------------*/
7272

73-
static SBKConv sbk_convertors[T_EOT] = {
73+
static const SBKConv sbk_convertors[T_EOT] = {
7474
NULL, NULL, NULL, NULL, NULL,
7575

7676
sbk_cutoff, sbk_filterQ, sbk_tenpct, sbk_panpos, sbk_atten, sbk_scale,

thirdparty/timidityplus/sffile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ void Instruments::free_soundfont(SFInfo *sf)
225225

226226
int Instruments::chunkid(char *id)
227227
{
228-
static struct idstring {
229-
const char *str;
228+
static const struct idstring {
229+
const char str[5];
230230
int id;
231231
} idlist[] = {
232232
{"RIFF", RIFF_ID},

thirdparty/timidityplus/smplfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Instrument *Instruments::extract_sample_file(char *sample_file)
127127
/* returns number of importers which may be suitable for the file */
128128
int Instruments::get_importers(const char *sample_file, int limit, SampleImporter **importers)
129129
{
130-
static SampleImporter sample_importers[] = {
130+
SampleImporter sample_importers[] = {
131131
{"wav", &Instruments::import_wave_discriminant, &Instruments::import_wave_load},
132132
{"aiff", &Instruments::import_aiff_discriminant, &Instruments::import_aiff_load},
133133
{NULL, NULL, NULL},

thirdparty/timidityplus/timiditypp/instrum.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ class Instruments
346346
SampleList *last_sample_list = nullptr;
347347

348348
LayerItem layer_items[SF_EOF];
349+
// formerly static function-local variables.
350+
int rcf_count = 0;
351+
char *last_name;
349352

350353
/* convert from 8bit value to fractional offset (15.15) */
351354
int32_t to_offset_22(int offset)

0 commit comments

Comments
 (0)