The number of elements is always two or three.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | #include "libavutil/attributes.h" |
| 27 | +#include "libavutil/avassert.h" | |
| 27 | 28 | #include "libavutil/common.h" |
| 28 | 29 | #include "libavutil/opt.h" |
| 29 | 30 | #include "avfilter.h" |
| @@ -134,20 +135,15 @@ static void gauss_solve_triangular(const double *A, const int *p, double *b, int · 104 unmodified lines | ||
| 134 | 135 | |
| 135 | 136 | static int gauss_solve(double *A, double *b, int n) |
| 136 | 137 | { |
| 137 | − int *p = av_calloc(n, sizeof(*p)); | |
| 138 | + int p[3] = { 0 }; | |
| 138 | 139 | |
| 139 | − if (!p) | |
| 140 | − return 1; | |
| 140 | + av_assert2(n <= FF_ARRAY_ELEMS(p)); | |
| 141 | 141 | |
| 142 | − if (!gauss_make_triangular(A, p, n)) { | |
| 143 | − av_freep(&p); | |
| 142 | + if (!gauss_make_triangular(A, p, n)) | |
| 144 | 143 | return 1; |
| 145 | − } | |
| 146 | 144 | |
| 147 | 145 | gauss_solve_triangular(A, p, b, n); |
| 148 | 146 | |
| 149 | − av_freep(&p); | |
| 150 | − | |
| 151 | 147 | return 0; |
| 152 | 148 | } |
| 153 | 149 | |