comparison opt.c @ 11801:026edf66e3a9 libavcodec

Make ff_parse_expr() and ff_parse_and_eval_expr() return an int containing an error code. Allow these functions to convey the reason of the failure to the calling function, failure which is not always due to a parsing error but it may depend for example on a memory problem. Also fix several potential memleaks.
author stefano
date Tue, 01 Jun 2010 08:07:07 +0000
parents c6368258b694
children e522dbf60abd
comparison
equal deleted inserted replaced
11800:966aa6b53dcf 11801:026edf66e3a9
163 else if(!strcmp(buf, "max" )) d= o->max; 163 else if(!strcmp(buf, "max" )) d= o->max;
164 else if(!strcmp(buf, "min" )) d= o->min; 164 else if(!strcmp(buf, "min" )) d= o->min;
165 else if(!strcmp(buf, "none" )) d= 0; 165 else if(!strcmp(buf, "none" )) d= 0;
166 else if(!strcmp(buf, "all" )) d= ~0; 166 else if(!strcmp(buf, "all" )) d= ~0;
167 else { 167 else {
168 d = ff_parse_and_eval_expr(buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); 168 int res = ff_parse_and_eval_expr(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj);
169 if (isnan(d)){ 169 if (res < 0) {
170 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); 170 av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val);
171 return AVERROR(EINVAL); 171 return res;
172 } 172 }
173 } 173 }
174 } 174 }
175 if(o->type == FF_OPT_TYPE_FLAGS){ 175 if(o->type == FF_OPT_TYPE_FLAGS){
176 if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d; 176 if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;