History

avfilter/vf_colormap: Avoid allocation of small array

The number of elements is always two or three.

Andreas Rheinhardt committed 4 years ago

Commit 8449fbd1 parent 9d2f4271 file · +4 −8Browse files

Unified · Split

libavfilter/vf_colormap.c+4−8
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 */
2525
2626 #include "libavutil/attributes.h"
27+#include "libavutil/avassert.h"
2728 #include "libavutil/common.h"
2829 #include "libavutil/opt.h"
2930 #include "avfilter.h"
@@ -134,20 +135,15 @@ static void gauss_solve_triangular(const double *A, const int *p, double *b, int · 104 unmodified lines
134135
135136 static int gauss_solve(double *A, double *b, int n)
136137 {
137− int *p = av_calloc(n, sizeof(*p));
138+ int p[3] = { 0 };
138139
139− if (!p)
140− return 1;
140+ av_assert2(n <= FF_ARRAY_ELEMS(p));
141141
142− if (!gauss_make_triangular(A, p, n)) {
143− av_freep(&p);
142+ if (!gauss_make_triangular(A, p, n))
144143 return 1;
145− }
146144
147145 gauss_solve_triangular(A, p, b, n);
148146
149− av_freep(&p);
150−
151147 return 0;
152148 }
153149

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t