[libav-devel] [PATCH 2/5] avstring: Const correct the return pointers of strstr-like functions

Luca Barbato lu_zero at gentoo.org
Mon Aug 3 22:51:49 CEST 2015


---
 libavutil/avstring.c | 5 +++--
 libavutil/avstring.h | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index eb5c95a..eb505de 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -51,7 +51,7 @@ int av_stristart(const char *str, const char *pfx, const char **ptr)
     return !*pfx;
 }
 
-char *av_stristr(const char *s1, const char *s2)
+const char *av_stristr(const char *s1, const char *s2)
 {
     if (!*s2)
         return s1;
@@ -64,7 +64,8 @@ char *av_stristr(const char *s1, const char *s2)
     return NULL;
 }
 
-char *av_strnstr(const char *haystack, const char *needle, size_t hay_length)
+const char *av_strnstr(const char *haystack, const char *needle,
+                       size_t hay_length)
 {
     size_t needle_len = strlen(needle);
     if (!needle_len)
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 7c30ee1..134bccd 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -64,7 +64,7 @@ int av_stristart(const char *str, const char *pfx, const char **ptr);
  * @return         pointer to the located match within haystack
  *                 or a null pointer if no match
  */
-char *av_stristr(const char *haystack, const char *needle);
+const char *av_stristr(const char *haystack, const char *needle);
 
 /**
  * Locate the first occurrence of the string needle in the string haystack
@@ -79,7 +79,8 @@ char *av_stristr(const char *haystack, const char *needle);
  * @return           pointer to the located match within haystack
  *                   or a null pointer if no match
  */
-char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
+const char *av_strnstr(const char *haystack, const char *needle,
+                       size_t hay_length);
 
 /**
  * Copy the string src to dst, but no more than size - 1 bytes, and
-- 
1.9.0



More information about the libav-devel mailing list