[FFmpeg-devel] [PATCH 3/8] improve get_line to return line length

Aurelien Jacobs aurel
Wed Jul 21 11:53:01 CEST 2010


---
 libavformat/aviobuf.c  |    5 +++--
 libavformat/internal.h |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 264d2de..5841966 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -554,18 +554,19 @@ char *get_strz(ByteIOContext *s, char *buf, int maxlen)
     return buf;
 }
 
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen)
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen)
 {
     int i = 0;
     char c;
 
     do {
         c = get_byte(s);
-        if (i < maxlen-1)
+        if (c && i < maxlen-1)
             buf[i++] = c;
     } while (c != '\n' && c);
 
     buf[i] = 0;
+    return i;
 }
 
 uint64_t get_be64(ByteIOContext *s)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 5833ef0..b746c1d 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -167,7 +167,7 @@ int ff_get_v_length(uint64_t val);
  */
 void ff_put_v(ByteIOContext *bc, uint64_t val);
 
-void ff_get_line(ByteIOContext *s, char *buf, int maxlen);
+int ff_get_line(ByteIOContext *s, char *buf, int maxlen);
 
 #define SPACE_CHARS " \t\r\n"
 




More information about the ffmpeg-devel mailing list