From: Lukasz Marek <[email protected]>

Also add const to pointers in static functions within opt.c where
possible.
---
Or can we freely add const here without waiting for a major bump?
I don't see any case where adding const actually would break third
party code.
---
 libavutil/opt.c     | 4 ++--
 libavutil/opt.h     | 3 ++-
 libavutil/version.h | 7 +++++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index b3435e0..5825a72 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -34,7 +34,7 @@
 #include "log.h"
 #include "mathematics.h"
 
-const AVOption *av_opt_next(void *obj, const AVOption *last)
+const AVOption *av_opt_next(FF_CONST_AVUTIL56 void *obj, const AVOption *last)
 {
     AVClass *class = *(AVClass**)obj;
     if (!last && class->option && class->option[0].name)
@@ -44,7 +44,7 @@ const AVOption *av_opt_next(void *obj, const AVOption *last)
     return NULL;
 }
 
-static int read_number(const AVOption *o, void *dst, double *num, int *den, 
int64_t *intnum)
+static int read_number(const AVOption *o, const void *dst, double *num, int 
*den, int64_t *intnum)
 {
     switch (o->type) {
     case AV_OPT_TYPE_FLAGS:     *intnum = *(unsigned int*)dst;return 0;
diff --git a/libavutil/opt.h b/libavutil/opt.h
index 8413206..6750753 100644
--- a/libavutil/opt.h
+++ b/libavutil/opt.h
@@ -31,6 +31,7 @@
 #include "avutil.h"
 #include "dict.h"
 #include "log.h"
+#include "version.h"
 
 /**
  * @defgroup avoptions AVOptions
@@ -448,7 +449,7 @@ const AVOption *av_opt_find2(void *obj, const char *name, 
const char *unit,
  *             or NULL
  * @return next AVOption or NULL
  */
-const AVOption *av_opt_next(void *obj, const AVOption *prev);
+const AVOption *av_opt_next(FF_CONST_AVUTIL56 void *obj, const AVOption *prev);
 
 /**
  * Iterate over AVOptions-enabled children of obj.
diff --git a/libavutil/version.h b/libavutil/version.h
index ebd548f..15be994 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -100,6 +100,13 @@
 #define FF_API_ERROR_FRAME              (LIBAVUTIL_VERSION_MAJOR < 56)
 #endif
 
+#ifndef FF_CONST_AVUTIL56
+#if LIBAVUTIL_VERSION_MAJOR >= 56
+#define FF_CONST_AVUTIL56 const
+#else
+#define FF_CONST_AVUTIL56
+#endif
+#endif
 
 /**
  * @}
-- 
2.5.4 (Apple Git-61)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to