comparison eval.c @ 8320:0de488aa4fb0 libavcodec

Add a few const qualifiers in appropriate places. patch by Anders Grnberg, galileo.m2 gmail com
author diego
date Sun, 14 Dec 2008 12:24:50 +0000
parents 5de6db4225d6
children e9d9d946f213
comparison
equal deleted inserted replaced
8319:3e7dd8cfa97f 8320:0de488aa4fb0
45 #endif 45 #endif
46 46
47 typedef struct Parser{ 47 typedef struct Parser{
48 int stack_index; 48 int stack_index;
49 char *s; 49 char *s;
50 double *const_value; 50 const double *const_value;
51 const char **const_name; // NULL terminated 51 const char * const *const_name; // NULL terminated
52 double (**func1)(void *, double a); // NULL terminated 52 double (**func1)(void *, double a); // NULL terminated
53 const char **func1_name; // NULL terminated 53 const char **func1_name; // NULL terminated
54 double (**func2)(void *, double a, double b); // NULL terminated 54 double (**func2)(void *, double a, double b); // NULL terminated
55 char **func2_name; // NULL terminated 55 const char **func2_name; // NULL terminated
56 void *opaque; 56 void *opaque;
57 const char **error; 57 const char **error;
58 #define VARS 10 58 #define VARS 10
59 double var[VARS]; 59 double var[VARS];
60 } Parser; 60 } Parser;
373 case e_gauss: return verify_expr(e->param[0]); 373 case e_gauss: return verify_expr(e->param[0]);
374 default: return verify_expr(e->param[0]) && verify_expr(e->param[1]); 374 default: return verify_expr(e->param[0]) && verify_expr(e->param[1]);
375 } 375 }
376 } 376 }
377 377
378 AVEvalExpr * ff_parse(const char *s, const char **const_name, 378 AVEvalExpr * ff_parse(const char *s, const char * const *const_name,
379 double (**func1)(void *, double), const char **func1_name, 379 double (**func1)(void *, double), const char **func1_name,
380 double (**func2)(void *, double, double), char **func2_name, 380 double (**func2)(void *, double, double), const char **func2_name,
381 const char **error){ 381 const char **error){
382 Parser p; 382 Parser p;
383 AVEvalExpr * e; 383 AVEvalExpr * e;
384 char w[strlen(s) + 1], * wp = w; 384 char w[strlen(s) + 1], * wp = w;
385 385
402 return NULL; 402 return NULL;
403 } 403 }
404 return e; 404 return e;
405 } 405 }
406 406
407 double ff_parse_eval(AVEvalExpr * e, double *const_value, void *opaque) { 407 double ff_parse_eval(AVEvalExpr * e, const double *const_value, void *opaque) {
408 Parser p; 408 Parser p;
409 409
410 p.const_value= const_value; 410 p.const_value= const_value;
411 p.opaque = opaque; 411 p.opaque = opaque;
412 return eval_expr(&p, e); 412 return eval_expr(&p, e);
413 } 413 }
414 414
415 double ff_eval2(const char *s, double *const_value, const char **const_name, 415 double ff_eval2(const char *s, const double *const_value, const char * const *const_name,
416 double (**func1)(void *, double), const char **func1_name, 416 double (**func1)(void *, double), const char **func1_name,
417 double (**func2)(void *, double, double), char **func2_name, 417 double (**func2)(void *, double, double), const char **func2_name,
418 void *opaque, const char **error){ 418 void *opaque, const char **error){
419 AVEvalExpr * e = ff_parse(s, const_name, func1, func1_name, func2, func2_name, error); 419 AVEvalExpr * e = ff_parse(s, const_name, func1, func1_name, func2, func2_name, error);
420 double d; 420 double d;
421 if (!e) return NAN; 421 if (!e) return NAN;
422 d = ff_parse_eval(e, const_value, opaque); 422 d = ff_parse_eval(e, const_value, opaque);