Skip to content
Permalink
Browse files

Remove freep warning (#1180)

  • Loading branch information
NilsIrl authored and cfsmp3 committed Jan 13, 2020
1 parent dad108b commit 78249045f83404a7d20ef4a659836b949cca9216
@@ -688,7 +688,7 @@ int processmp4 (struct lib_ccx_ctx *ctx, struct ccx_s_mp4Cfg *cfg, char *file)

}

freep(&dec_ctx->xds_ctx);
freep(dec_ctx->xds_ctx);

mprint("\nClosing media: ");
gf_isom_close(f);
@@ -26,7 +26,7 @@ void dinit_avc(struct avc_ctx **ctx)
mprint ("Total caption blocks received: %d\n", lctx->ccblocks_in_avc_total);
mprint ("Total caption blocks lost: %d\n", lctx->ccblocks_in_avc_lost);
}
freep(&lctx->cc_data);
freep(lctx->cc_data);
freep(ctx);
}

@@ -58,16 +58,6 @@ void millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes,
*hours = (int)milli;
}

/* Frees the given pointer */
void freep(void **arg)
{
if (arg)
{
free(*arg);
*arg = NULL;
}
}

int add_cc_sub_text(struct cc_subtitle *sub, char *str, LLONG start_time,
LLONG end_time, char *info, char *mode, enum ccx_encoding_type e_type)
{
@@ -42,7 +42,9 @@
// Declarations
void fdprintf(int fd, const char *fmt, ...);
void millis_to_time(LLONG milli, unsigned *hours, unsigned *minutes,unsigned *seconds, unsigned *ms);
void freep(void **arg);

#define freep(ptr) do { free(ptr); ptr = NULL; } while (0);

void dbg_print(LLONG mask, const char *fmt, ...);
unsigned char *debug_608_to_ASC(unsigned char *ccdata, int channel);
int add_cc_sub_text(struct cc_subtitle *sub, char *str, LLONG start_time,
@@ -534,32 +534,32 @@ void free_encoder_context(struct encoder_ctx *ctx)
if (!ctx)
return;

freep(&ctx->first_input_file);
freep(&ctx->buffer);
freep(&ctx->out);
freep(&ctx->timing);
freep(&ctx->transcript_settings);
freep(&ctx->subline);
freep(&ctx->start_credits_text);
freep(&ctx->end_credits_text);
freep(&ctx->prev);
freep(&ctx->last_string);
freep(&ctx);
freep(ctx->first_input_file);
freep(ctx->buffer);
freep(ctx->out);
freep(ctx->timing);
freep(ctx->transcript_settings);
freep(ctx->subline);
freep(ctx->start_credits_text);
freep(ctx->end_credits_text);
freep(ctx->prev);
freep(ctx->last_string);
freep(ctx);
}
void free_decoder_context(struct lib_cc_decode *ctx)
{
if (!ctx)
return;

freep(&ctx->context_cc608_field_1);
freep(&ctx->context_cc608_field_2);
freep(&ctx->timing);
freep(&ctx->avc_ctx);
freep(&ctx->private_data);
freep(&ctx->dtvcc);
freep(&ctx->xds_ctx);
freep(&ctx->vbi_decoder);
freep(&ctx);
freep(ctx->context_cc608_field_1);
freep(ctx->context_cc608_field_2);
freep(ctx->timing);
freep(ctx->avc_ctx);
freep(ctx->private_data);
freep(ctx->dtvcc);
freep(ctx->xds_ctx);
freep(ctx->vbi_decoder);
freep(ctx);
}
void free_subtitle(struct cc_subtitle* sub)
{
@@ -571,10 +571,10 @@ void free_subtitle(struct cc_subtitle* sub)
struct cc_bitmap *bitmap=(struct cc_bitmap *) sub->data;
if (bitmap)
{
freep(&bitmap->data0);
freep(&bitmap->data1);
freep(bitmap->data0);
freep(bitmap->data1);
}
}
freep(&sub->data);
freep(&sub);
freep(sub->data);
freep(sub);
}
@@ -131,7 +131,7 @@ int write_xds_string(struct cc_subtitle *sub, struct ccx_decoders_xds_context *c
data = (struct eia608_screen *) realloc(sub->data,( sub->nb_data + 1 ) * sizeof(*data));
if (!data)
{
freep(&sub->data);
freep(sub->data);
sub->nb_data = 0;
ccx_common_logging.log_ftn("No Memory left");
return -1;
@@ -276,7 +276,7 @@ void ccx_demuxer_delete(struct ccx_demuxer **ctx)
struct ccx_demuxer *lctx = *ctx;
int i;
dinit_cap(lctx);
freep(&lctx->last_pat_payload);
freep(lctx->last_pat_payload);
for (i = 0; i < MAX_PSI_PID; i++)
{
if(lctx->PID_buffers[i]!=NULL && lctx->PID_buffers[i]->buffer!=NULL)
@@ -285,17 +285,17 @@ void ccx_demuxer_delete(struct ccx_demuxer **ctx)
lctx->PID_buffers[i]->buffer=NULL;
lctx->PID_buffers[i]->buffer_length=0;
}
freep(&lctx->PID_buffers[i]);
freep(lctx->PID_buffers[i]);
}
for (i = 0; i < MAX_PID; i++)
{
if( lctx->PIDs_programs[i])
freep(lctx->PIDs_programs + i);
freep(lctx->PIDs_programs[i]);
}
if (lctx->fh_out_elementarystream != NULL)
fclose (lctx->fh_out_elementarystream);

freep(&lctx->filebuffer);
freep(lctx->filebuffer);
freep(ctx);
}

@@ -584,14 +584,14 @@ int write_cc_subtitle_as_simplexml(struct cc_subtitle *sub, struct encoder_ctx *

} while ( (str = strtok_r(NULL, "\r\n", &save_str) ));

freep(&sub->data);
freep(sub->data);
lsub = sub;
sub = sub->next;
}
while(lsub != osub)
{
sub = lsub->prev;
freep(&lsub);
freep(lsub);
lsub = sub;
}

@@ -644,7 +644,7 @@ int write_cc_bitmap_as_simplexml(struct cc_subtitle *sub, struct encoder_ctx *co
int ret = 0;

sub->nb_data = 0;
freep(&sub->data);
freep(sub->data);
return ret;
}

@@ -764,7 +764,7 @@ static void dinit_output_ctx(struct encoder_ctx *ctx)
int i;
for(i = 0; i < ctx->nb_out; i++)
dinit_write(ctx->out + i);
freep(&ctx->out);
freep(ctx->out);

if (ctx->dtvcc_extract)
{
@@ -846,8 +846,8 @@ static int init_output_ctx(struct encoder_ctx *ctx, struct encoder_cfg *cfg)
}
}

freep(&basefilename);
freep(&extension);
freep(basefilename);
freep(extension);
}

if (cfg->cc_to_stdout == CCX_TRUE)
@@ -927,8 +927,8 @@ void dinit_encoder(struct encoder_ctx **arg, LLONG current_fts)

free_encoder_context(ctx->prev);
dinit_output_ctx(ctx);
freep(&ctx->subline);
freep(&ctx->buffer);
freep(ctx->subline);
freep(ctx->buffer);
ctx->capacity = 0;
freep(arg);
}
@@ -973,7 +973,7 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
ret = init_output_ctx(ctx, opt);
if (ret != EXIT_OK)
{
freep(&ctx->buffer);
freep(ctx->buffer);
free(ctx);
return NULL;
}
@@ -1012,8 +1012,8 @@ struct encoder_ctx *init_encoder(struct encoder_cfg *opt)
ctx->subline = (unsigned char *) malloc (SUBLINESIZE);
if(!ctx->subline)
{
freep(&ctx->out);
freep(&ctx->buffer);
freep(ctx->out);
freep(ctx->buffer);
free(ctx);
return NULL;
}
@@ -1128,7 +1128,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
mprint("WARNING:Loss of data\n");
}
}
freep(&data->xds_str);
freep(data->xds_str);
write_newline(context, 0);
continue;
}
@@ -1203,7 +1203,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
write_cc_buffer_to_gui(sub->data, context);
#endif // PYTHON_API
}
freep(&sub->data);
freep(sub->data);
}
if (sub->type == CC_BITMAP)
{
@@ -1311,7 +1311,7 @@ int encode_sub(struct encoder_ctx *context, struct cc_subtitle *sub)
}

if (!sub->nb_data)
freep(&sub->data);
freep(sub->data);
if (wrote_something && context->force_flush)
fsync(context->out->fh); // Don't buffer
return wrote_something;
@@ -78,7 +78,7 @@ int write_cc_bitmap_as_libcurl(struct cc_subtitle *sub, struct encoder_ctx *cont
mprint("curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
freep(&str);
freep(str);
}
for (i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
@@ -87,7 +87,7 @@ int write_cc_bitmap_as_libcurl(struct cc_subtitle *sub, struct encoder_ctx *cont
}
#endif
sub->nb_data = 0;
freep(&sub->data);
freep(sub->data);
return ret;

}
@@ -163,7 +163,7 @@ int write_cc_bitmap_as_sami(struct cc_subtitle *sub, struct encoder_ctx *context
#endif

sub->nb_data = 0;
freep(&sub->data);
freep(sub->data);
return ret;
}

@@ -177,7 +177,7 @@ int write_cc_subtitle_as_sami(struct cc_subtitle *sub, struct encoder_ctx *conte
if(sub->type == CC_TEXT)
{
ret = write_stringz_as_sami(sub->data, context, sub->start_time, sub->end_time);
freep(&sub->data);
freep(sub->data);
sub->nb_data = 0;
}
lsub = sub;
@@ -186,7 +186,7 @@ int write_cc_subtitle_as_sami(struct cc_subtitle *sub, struct encoder_ctx *conte
while(lsub != osub)
{
sub = lsub->prev;
freep(&lsub);
freep(lsub);
lsub = sub;
}

@@ -147,13 +147,13 @@ int write_cc_bitmap_as_smptett(struct cc_subtitle *sub, struct encoder_ctx *cont
}
for (i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
freep(&rect->data0);
freep(&rect->data1);
freep(rect->data0);
freep(rect->data1);
}
#endif

sub->nb_data = 0;
freep(&sub->data);
freep(sub->data);
return ret;

}
@@ -168,7 +168,7 @@ int write_cc_subtitle_as_smptett(struct cc_subtitle *sub, struct encoder_ctx *co
if(sub->type == CC_TEXT)
{
write_stringz_as_smptett(sub->data, context, sub->start_time, sub->end_time);
freep(&sub->data);
freep(sub->data);
sub->nb_data = 0;
}
lsub = sub;
@@ -177,7 +177,7 @@ int write_cc_subtitle_as_smptett(struct cc_subtitle *sub, struct encoder_ctx *co
while(lsub != osub)
{
sub = lsub->prev;
freep(&lsub);
freep(lsub);
lsub = sub;
}

@@ -422,8 +422,8 @@ int write_cc_buffer_as_smptett(struct eia608_screen *data, struct encoder_ctx *c
used = encode_line(context, context->buffer, (unsigned char*) str);
//write (wb->fh, enc_buffer,enc_buffer_used);

freep(&final);
freep(&temp);
freep(final);
freep(temp);

}
}
@@ -772,17 +772,17 @@ struct cc_subtitle * reformat_cc_bitmap_through_sentence_buffer(struct cc_subtit
{
resub = sbs_append_string(str, ms_start, ms_end, sbs_init_context());
}
freep(&str);
freep(str);
}

for(i = 0, rect = sub->data; i < sub->nb_data; i++, rect++)
{
freep(&rect->data0);
freep(&rect->data1);
freep(rect->data0);
freep(rect->data1);
}
#endif
sub->nb_data = 0;
freep(&sub->data);
freep(sub->data);

return resub;
}

0 comments on commit 7824904

Please sign in to comment.
You can’t perform that action at this time.