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
24 */24 */
25 25
26#include "libavutil/attributes.h"26#include "libavutil/attributes.h"
27#include "libavutil/avassert.h"
27#include "libavutil/common.h"28#include "libavutil/common.h"
28#include "libavutil/opt.h"29#include "libavutil/opt.h"
29#include "avfilter.h"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
135static int gauss_solve(double *A, double *b, int n)136static 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 av_assert2(n <= FF_ARRAY_ELEMS(p));
140 return 1;
141 141
142 if (!gauss_make_triangular(A, p, n)) {142 if (!gauss_make_triangular(A, p, n))
143 av_freep(&p);
144 return 1;143 return 1;
145 }
146 144
147 gauss_solve_triangular(A, p, b, n);145 gauss_solve_triangular(A, p, b, n);
148 146
149 av_freep(&p);
150
151 return 0;147 return 0;
152}148}
153 149

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