Make analysis happy and prefer heap over stack.

This commit is contained in:
QC 2015-01-10 15:13:10 +01:00
parent 479123fcef
commit 7e6a24f9b6
1 changed files with 5 additions and 2 deletions

View File

@ -781,15 +781,18 @@ static int levenshtein ( const char *s, const char *t )
{
int ls = strlen ( s ), lt = strlen ( t );
size_t array_length = ( ls + 1 ) * ( lt + 1 );
// For some reason Coverity does not get that I initialize the
// array in for loop.
int d[array_length];
int *d = g_malloc_n ( array_length, sizeof ( int ) );
for ( size_t i = 0; i < array_length; i++ ) {
d[i] = -1;
}
return dist ( s, t, d, ls, lt, 0, 0 );
int retv = dist ( s, t, d, ls, lt, 0, 0 );
g_free ( d );
return retv;
}
static void window_set_opacity ( Display *display, Window box, unsigned int opacity )