Cleanup, use av_freep() instead of av_free(x); x=NULL

Originally committed as revision 27331 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale
This commit is contained in:
Michael Niedermayer 2008-07-21 11:18:24 +00:00
parent 582b354933
commit 47b7382d29

View File

@ -1144,7 +1144,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
if (outVec != &scaleFilter) sws_freeVec(outVec);
}
av_free(filter); filter=NULL;
av_freep(&filter);
/* try to reduce the filter-size (step1 find size and shift left) */
// Assume it is near normalized (*0.5 or *2.0 is OK but * 0.001 is not).
@ -1228,7 +1228,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
else filter[i*filterSize + j]= filter2[i*filter2Size + j];
}
}
av_free(filter2); filter2=NULL;
av_freep(&filter2);
//FIXME try to align filterpos if possible
@ -2821,8 +2821,7 @@ void sws_printVec(SwsVector *a){
void sws_freeVec(SwsVector *a){
if (!a) return;
av_free(a->coeff);
a->coeff=NULL;
av_freep(&a->coeff);
a->length=0;
av_free(a);
}
@ -2845,48 +2844,30 @@ void sws_freeContext(SwsContext *c){
if (c->lumPixBuf)
{
for (i=0; i<c->vLumBufSize; i++)
{
av_free(c->lumPixBuf[i]);
c->lumPixBuf[i]=NULL;
}
av_free(c->lumPixBuf);
c->lumPixBuf=NULL;
av_freep(&c->lumPixBuf[i]);
av_freep(&c->lumPixBuf);
}
if (c->chrPixBuf)
{
for (i=0; i<c->vChrBufSize; i++)
{
av_free(c->chrPixBuf[i]);
c->chrPixBuf[i]=NULL;
}
av_free(c->chrPixBuf);
c->chrPixBuf=NULL;
av_freep(&c->chrPixBuf[i]);
av_freep(&c->chrPixBuf);
}
av_free(c->vLumFilter);
c->vLumFilter = NULL;
av_free(c->vChrFilter);
c->vChrFilter = NULL;
av_free(c->hLumFilter);
c->hLumFilter = NULL;
av_free(c->hChrFilter);
c->hChrFilter = NULL;
av_freep(&c->vLumFilter);
av_freep(&c->vChrFilter);
av_freep(&c->hLumFilter);
av_freep(&c->hChrFilter);
#ifdef HAVE_ALTIVEC
av_free(c->vYCoeffsBank);
c->vYCoeffsBank = NULL;
av_free(c->vCCoeffsBank);
c->vCCoeffsBank = NULL;
av_freep(&c->vYCoeffsBank);
av_freep(&c->vCCoeffsBank);
#endif
av_free(c->vLumFilterPos);
c->vLumFilterPos = NULL;
av_free(c->vChrFilterPos);
c->vChrFilterPos = NULL;
av_free(c->hLumFilterPos);
c->hLumFilterPos = NULL;
av_free(c->hChrFilterPos);
c->hChrFilterPos = NULL;
av_freep(&c->vLumFilterPos);
av_freep(&c->vChrFilterPos);
av_freep(&c->hLumFilterPos);
av_freep(&c->hChrFilterPos);
#if defined(ARCH_X86) && defined(CONFIG_GPL)
#ifdef MAP_ANONYMOUS
@ -2900,16 +2881,11 @@ void sws_freeContext(SwsContext *c){
c->funnyUVCode=NULL;
#endif /* defined(ARCH_X86) */
av_free(c->lumMmx2Filter);
c->lumMmx2Filter=NULL;
av_free(c->chrMmx2Filter);
c->chrMmx2Filter=NULL;
av_free(c->lumMmx2FilterPos);
c->lumMmx2FilterPos=NULL;
av_free(c->chrMmx2FilterPos);
c->chrMmx2FilterPos=NULL;
av_free(c->yuvTable);
c->yuvTable=NULL;
av_freep(&c->lumMmx2Filter);
av_freep(&c->chrMmx2Filter);
av_freep(&c->lumMmx2FilterPos);
av_freep(&c->chrMmx2FilterPos);
av_freep(&c->yuvTable);
av_free(c);
}