diff --git a/src/608.c b/src/608.c index 8cf36b3c..b42020e8 100644 --- a/src/608.c +++ b/src/608.c @@ -1,6 +1,7 @@ #include "ccextractor.h" #include "608_spupng.h" #include "cc_decoders_common.h" +#include "utility.h" static const int rowdata[] = {11,-1,1,2,3,4,12,13,14,15,5,6,7,8,9,10}; // Relationship between the first PAC byte and the row number @@ -585,11 +586,8 @@ int write_cc_buffer(struct s_context_cc608 *context) if (ccx_options.gui_mode_reports) write_cc_buffer_to_gui(data, context); data = (struct eia608_screen*)sub->data + 1; - if (sub->data && !sub->size) - { - free(sub->data); - sub->data = NULL; - } + if (!sub->size) + freep(&sub->data); } return wrote_something; diff --git a/src/dvb_subtitle_decoder.c b/src/dvb_subtitle_decoder.c index f24c8340..060b654d 100644 --- a/src/dvb_subtitle_decoder.c +++ b/src/dvb_subtitle_decoder.c @@ -188,15 +188,6 @@ static __inline unsigned int get_bits1(GetBitContext *s) return result; } - -static void freep(void *arg) -{ - void **ptr = (void **) arg; - if (*ptr) - free(*ptr); - *ptr = NULL; - -} #ifdef DEBUG struct transIntensity diff --git a/src/utility.c b/src/utility.c index 1e3c387f..86f750a3 100644 --- a/src/utility.c +++ b/src/utility.c @@ -336,3 +336,12 @@ int string_cmp(const void *p1,const void *p2) { return string_cmp2(p1, p2, NULL); } + +void freep(void *arg) +{ + void **ptr = (void **) arg; + if (*ptr) + free(*ptr); + *ptr = NULL; + +} diff --git a/src/utility.h b/src/utility.h index c5ab031f..9ebb2675 100644 --- a/src/utility.h +++ b/src/utility.h @@ -13,5 +13,6 @@ void shell_sort(void *base, int nb,size_t size,int (*compar)(const void*p1,const void *p2,void*arg),void *arg); int string_cmp(const void *p1,const void *p2); int string_cmp2(const void *p1,const void *p2,void *arg); +void freep(void *arg); #endif