---
Since av_freep has become a (quasi) first class citizen, this small set
takes care of replacing every occurence in sws, lavd, lavr and lavfi.
They have been obtained by a sed automation and several rounds of human
and coverity reviews. Oracle didn't report any particular problem.
Cheers,
Vittorio
libswscale/swscale-test.c | 8 ++++----
libswscale/utils.c | 34 +++++++++++++++++-----------------
libswscale/yuv2rgb.c | 2 +-
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/libswscale/swscale-test.c b/libswscale/swscale-test.c
index 8063519..f87a381 100644
--- a/libswscale/swscale-test.c
+++ b/libswscale/swscale-test.c
@@ -219,7 +219,7 @@ static int doTest(uint8_t *ref[4], int refStride[4], int w,
int h,
for (i = 0; i < 4; i++)
if (refStride[i])
- av_free(out[i]);
+ av_freep(&out[i]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
@@ -230,7 +230,7 @@ end:
for (i = 0; i < 4; i++)
if (dstStride[i])
- av_free(dst[i]);
+ av_freep(&dst[i]);
return res;
}
@@ -368,7 +368,7 @@ int main(int argc, char **argv)
rgb_data[ x + y * 4 * W] = av_lfg_get(&rand);
sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
sws_freeContext(sws);
- av_free(rgb_data);
+ av_freep(&rgb_data);
for (i = 1; i < argc; i += 2) {
if (argv[i][0] != '-' || i + 1 == argc)
@@ -405,7 +405,7 @@ bad_option:
end:
res = 0;
error:
- av_free(data);
+ av_freep(&data);
return res;
}
diff --git a/libswscale/utils.c b/libswscale/utils.c
index b3df1af..6ea23a0 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -431,7 +431,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t
**filterPos,
}
/* apply src & dst Filter to filter -> filter2
- * av_free(filter);
+ * av_freep(&filter);
*/
assert(filterSize > 0);
filter2Size = filterSize;
@@ -614,8 +614,8 @@ static av_cold int initFilter(int16_t **outFilter, int32_t
**filterPos,
ret = 0;
fail:
- av_free(filter);
- av_free(filter2);
+ av_freep(&filter);
+ av_freep(&filter2);
return ret;
}
@@ -1568,37 +1568,37 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int
shift)
void sws_shiftVec(SwsVector *a, int shift)
{
SwsVector *shifted = sws_getShiftedVec(a, shift);
- av_free(a->coeff);
+ av_freep(&a->coeff);
a->coeff = shifted->coeff;
a->length = shifted->length;
- av_free(shifted);
+ av_freep(&shifted);
}
void sws_addVec(SwsVector *a, SwsVector *b)
{
SwsVector *sum = sws_sumVec(a, b);
- av_free(a->coeff);
+ av_freep(&a->coeff);
a->coeff = sum->coeff;
a->length = sum->length;
- av_free(sum);
+ av_freep(&sum);
}
void sws_subVec(SwsVector *a, SwsVector *b)
{
SwsVector *diff = sws_diffVec(a, b);
- av_free(a->coeff);
+ av_freep(&a->coeff);
a->coeff = diff->coeff;
a->length = diff->length;
- av_free(diff);
+ av_freep(&diff);
}
void sws_convVec(SwsVector *a, SwsVector *b)
{
SwsVector *conv = sws_getConvVec(a, b);
- av_free(a->coeff);
+ av_freep(&a->coeff);
a->coeff = conv->coeff;
a->length = conv->length;
- av_free(conv);
+ av_freep(&conv);
}
SwsVector *sws_cloneVec(SwsVector *a)
@@ -1647,7 +1647,7 @@ void sws_freeVec(SwsVector *a)
return;
av_freep(&a->coeff);
a->length = 0;
- av_free(a);
+ av_freep(&a);
}
void sws_freeFilter(SwsFilter *filter)
@@ -1663,7 +1663,7 @@ void sws_freeFilter(SwsFilter *filter)
sws_freeVec(filter->chrH);
if (filter->chrV)
sws_freeVec(filter->chrV);
- av_free(filter);
+ av_freep(&filter);
}
void sws_freeContext(SwsContext *c)
@@ -1717,17 +1717,17 @@ void sws_freeContext(SwsContext *c)
if (c->chrMmxextFilterCode)
VirtualFree(c->chrMmxextFilterCode, 0, MEM_RELEASE);
#else
- av_free(c->lumMmxextFilterCode);
- av_free(c->chrMmxextFilterCode);
+ av_freep(&c->lumMmxextFilterCode);
+ av_freep(&c->chrMmxextFilterCode);
#endif
c->lumMmxextFilterCode = NULL;
c->chrMmxextFilterCode = NULL;
#endif /* HAVE_MMX_INLINE */
av_freep(&c->yuvTable);
- av_free(c->formatConvBuffer);
+ av_freep(&c->formatConvBuffer);
- av_free(c);
+ av_freep(&c);
}
struct SwsContext *sws_getCachedContext(struct SwsContext *context, int srcW,
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index a4f7a11..aaf5833 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -734,7 +734,7 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const
int inv_table[4],
cgu = ((cgu << 16) + 0x8000) / cy;
cgv = ((cgv << 16) + 0x8000) / cy;
- av_free(c->yuvTable);
+ av_freep(&c->yuvTable);
#define ALLOC_YUV_TABLE(x) \
c->yuvTable = av_malloc(x); \
--
1.9.3 (Apple Git-50)
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel