Merge commit '636ced8e1dc8248a1353b416240b93d70ad03edb'
* commit '636ced8e1dc8248a1353b416240b93d70ad03edb': cmdutils: wrap exit explicitly Conflicts: avprobe.c cmdutils.c ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
31
cmdutils.c
31
cmdutils.c
@ -111,6 +111,21 @@ static void log_callback_report(void *ptr, int level, const char *fmt, va_list v
|
||||
fflush(report_file);
|
||||
}
|
||||
|
||||
static void (*program_exit)(int ret);
|
||||
|
||||
void register_exit(void (*cb)(int ret))
|
||||
{
|
||||
program_exit = cb;
|
||||
}
|
||||
|
||||
void exit_program(int ret)
|
||||
{
|
||||
if (program_exit)
|
||||
program_exit(ret);
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
double parse_number_or_die(const char *context, const char *numstr, int type,
|
||||
double min, double max)
|
||||
{
|
||||
@ -128,7 +143,7 @@ double parse_number_or_die(const char *context, const char *numstr, int type,
|
||||
else
|
||||
return d;
|
||||
av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max);
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -139,7 +154,7 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
|
||||
if (av_parse_time(&us, timestr, is_duration) < 0) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n",
|
||||
is_duration ? "duration" : "date", context, timestr);
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
}
|
||||
return us;
|
||||
}
|
||||
@ -304,7 +319,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
|
||||
}
|
||||
}
|
||||
if (po->flags & OPT_EXIT)
|
||||
exit(0);
|
||||
exit_program(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -364,7 +379,7 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options
|
||||
opt++;
|
||||
|
||||
if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
optindex += ret;
|
||||
} else {
|
||||
if (parse_arg_function)
|
||||
@ -637,7 +652,7 @@ static void init_parse_context(OptionParseContext *octx,
|
||||
octx->nb_groups = nb_groups;
|
||||
octx->groups = av_mallocz(sizeof(*octx->groups) * octx->nb_groups);
|
||||
if (!octx->groups)
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
|
||||
for (i = 0; i < octx->nb_groups; i++)
|
||||
octx->groups[i].group_def = &groups[i];
|
||||
@ -817,7 +832,7 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg)
|
||||
"Possible levels are numbers or:\n", arg);
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++)
|
||||
av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name);
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
}
|
||||
av_log_set_level(level);
|
||||
return 0;
|
||||
@ -1924,13 +1939,13 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
|
||||
{
|
||||
if (new_size >= INT_MAX / elem_size) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
}
|
||||
if (*size < new_size) {
|
||||
uint8_t *tmp = av_realloc(array, new_size*elem_size);
|
||||
if (!tmp) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n");
|
||||
exit(1);
|
||||
exit_program(1);
|
||||
}
|
||||
memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size);
|
||||
*size = new_size;
|
||||
|
Reference in New Issue
Block a user