Mixer: Cope with some plugins having insane numbers of parameters.
This commit is contained in:
parent
e909d9594b
commit
0f8017a1ef
|
@ -710,18 +710,21 @@ Module::chain ( Chain *v )
|
|||
char *
|
||||
Module::get_parameters ( void ) const
|
||||
{
|
||||
char *s = new char[1024];
|
||||
int len = control_input.size() * 50;
|
||||
char *s = new char[ len ];
|
||||
|
||||
s[0] = 0;
|
||||
char *sp = s;
|
||||
|
||||
if ( control_input.size() )
|
||||
{
|
||||
for ( unsigned int i = 0; i < control_input.size(); ++i )
|
||||
sp += snprintf( sp, 1024 - (sp - s),"%f:", control_input[i].control_value() );
|
||||
sp += snprintf( sp, len - (sp - s),"%f:", control_input[i].control_value() );
|
||||
|
||||
*(sp - 1) = '\0';
|
||||
}
|
||||
|
||||
/* DMESSAGE("get_parameters: %s",s); */
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ unescape ( char *s )
|
|||
char *
|
||||
Log_Entry::print ( void ) const
|
||||
{
|
||||
/* FIXME: gross over-allocation */
|
||||
char *r = (char*)malloc( 1024 );
|
||||
|
||||
r[0] = 0;
|
||||
|
@ -105,20 +104,17 @@ Log_Entry::print ( void ) const
|
|||
|
||||
get( i, &s, &v );
|
||||
|
||||
/* FIXME: arbitrary limit */
|
||||
char t[1024];
|
||||
snprintf( t, sizeof( t ), "%s %s%s", s, v, size() == i + 1 ? "" : " " );
|
||||
char *t;
|
||||
asprintf( &t, "%s %s%s", s, v, size() == i + 1 ? "" : " " );
|
||||
|
||||
r = (char*)realloc( r, strlen(r) + strlen(t) + 1 );
|
||||
|
||||
strcat( r, t );
|
||||
|
||||
free(t);
|
||||
}
|
||||
|
||||
char *r2 = (char*)malloc( strlen( r ) + 1 );
|
||||
|
||||
strcpy( r2, r );
|
||||
|
||||
free( r );
|
||||
|
||||
return r2;
|
||||
return r;
|
||||
}
|
||||
|
||||
/** sigh. parse a string of ":name value :name value" pairs into an
|
||||
|
|
|
@ -346,10 +346,18 @@ Loggable::update_id ( unsigned int id )
|
|||
const char *
|
||||
Loggable::escape ( const char *s )
|
||||
{
|
||||
static char r[512];
|
||||
static size_t rl = 256;
|
||||
static char *r = new char[rl + 1];
|
||||
|
||||
if ( strlen(s) * 2 > rl )
|
||||
{
|
||||
delete []r;
|
||||
rl = strlen(s) * 2;
|
||||
r = new char[ rl + 1 ];
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
for ( ; *s && i < sizeof( r ); ++i, ++s )
|
||||
for ( ; *s && i < rl; ++i, ++s )
|
||||
{
|
||||
if ( '\n' == *s )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue