mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
replace standards-wobbling variable-length-arrays with alloca()
This commit is contained in:
parent
b8d31a370a
commit
10d577146a
1 changed files with 16 additions and 7 deletions
|
|
@ -34,6 +34,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <alloca.h>
|
||||||
|
|
||||||
#include "pbd/cartesian.h"
|
#include "pbd/cartesian.h"
|
||||||
|
|
||||||
|
|
@ -115,10 +116,14 @@ VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets)
|
||||||
|
|
||||||
int i,j,k,l,table_size;
|
int i,j,k,l,table_size;
|
||||||
int n_speakers = _speakers.size ();
|
int n_speakers = _speakers.size ();
|
||||||
int connections[n_speakers][n_speakers];
|
/* variable length arrays arrived in C99, became optional in C11, and
|
||||||
float distance_table[((n_speakers * (n_speakers - 1)) / 2)];
|
are only planned for C++14. Use alloca which is functionally
|
||||||
int distance_table_i[((n_speakers * (n_speakers - 1)) / 2)];
|
identical (but uglier to read).
|
||||||
int distance_table_j[((n_speakers * (n_speakers - 1)) / 2)];
|
*/
|
||||||
|
int** connections = (int**) alloca (sizeof (int) * n_speakers * n_speakers);
|
||||||
|
float* distance_table = (float *) alloca (sizeof (float) * ((n_speakers * (n_speakers - 1)) / 2));
|
||||||
|
int* distance_table_i = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2));
|
||||||
|
int* distance_table_j = (int *) alloca (sizeof (int) * ((n_speakers * (n_speakers - 1)) / 2));
|
||||||
float distance;
|
float distance;
|
||||||
struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr;
|
struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr;
|
||||||
|
|
||||||
|
|
@ -527,9 +532,13 @@ VBAPSpeakers::choose_speaker_pairs (){
|
||||||
*/
|
*/
|
||||||
const int n_speakers = _speakers.size();
|
const int n_speakers = _speakers.size();
|
||||||
const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175);
|
const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175);
|
||||||
int sorted_speakers[n_speakers];
|
/* variable length arrays arrived in C99, became optional in C11, and
|
||||||
bool exists[n_speakers];
|
are only planned for C++14. Use alloca which is functionally
|
||||||
double inverse_matrix[n_speakers][4];
|
identical (but uglier to read).
|
||||||
|
*/
|
||||||
|
int* sorted_speakers = (int*) alloca (sizeof (int) * n_speakers);
|
||||||
|
bool* exists = (bool*) alloca (sizeof(bool) * n_speakers);
|
||||||
|
double** inverse_matrix = (double**) alloca (sizeof (double) * n_speakers * 4);
|
||||||
int expected_pairs = 0;
|
int expected_pairs = 0;
|
||||||
int pair;
|
int pair;
|
||||||
int speaker;
|
int speaker;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue