Re: [FFmpeg-devel] [PATCH] lavf/mpegtsenc: move putstr8 definition up
On date Saturday 2016-05-21 22:14:22 +0200, Benoit Fouet encoded: > Hi, > > Le 19/05/2016 18:45, Stefano Sabatini a écrit : > >This allows to use the function in a future commit. > >--- > > libavformat/mpegtsenc.c | 34 +- > > 1 file changed, 17 insertions(+), 17 deletions(-) > > > >diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > >index 93cbac1..5f22032 100644 > >--- a/libavformat/mpegtsenc.c > >+++ b/libavformat/mpegtsenc.c > >@@ -253,6 +253,23 @@ static void mpegts_write_pat(AVFormatContext *s) > >data, q - data); > > } > >+/* NOTE: !str is accepted for an empty string */ > >+static void putstr8(uint8_t **q_ptr, const char *str) > >+{ > >+uint8_t *q; > >+int len; > >+ > >+q = *q_ptr; > >+if (!str) > >+len = 0; > >+else > >+len = strlen(str); > >+*q++ = len; > >+memcpy(q, str, len); > > Side note on this one, unrelated to your change. > Isn't this undefined behavior to call memcpy with one of the > pointers being NULL? Yes, even if in practice doesn't seem to matter since we set len = 0. -- FFmpeg = Fancy Fascinating MultiPurpose Enhancing Guide ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/mpegtsenc: move putstr8 definition up
Hi, Le 19/05/2016 18:45, Stefano Sabatini a écrit : This allows to use the function in a future commit. --- libavformat/mpegtsenc.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 93cbac1..5f22032 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -253,6 +253,23 @@ static void mpegts_write_pat(AVFormatContext *s) data, q - data); } +/* NOTE: !str is accepted for an empty string */ +static void putstr8(uint8_t **q_ptr, const char *str) +{ +uint8_t *q; +int len; + +q = *q_ptr; +if (!str) +len = 0; +else +len = strlen(str); +*q++ = len; +memcpy(q, str, len); Side note on this one, unrelated to your change. Isn't this undefined behavior to call memcpy with one of the pointers being NULL? -- Ben ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavf/mpegtsenc: move putstr8 definition up
This allows to use the function in a future commit. --- libavformat/mpegtsenc.c | 34 +- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 93cbac1..5f22032 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -253,6 +253,23 @@ static void mpegts_write_pat(AVFormatContext *s) data, q - data); } +/* NOTE: !str is accepted for an empty string */ +static void putstr8(uint8_t **q_ptr, const char *str) +{ +uint8_t *q; +int len; + +q = *q_ptr; +if (!str) +len = 0; +else +len = strlen(str); +*q++ = len; +memcpy(q, str, len); +q += len; +*q_ptr = q; +} + static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) { MpegTSWrite *ts = s->priv_data; @@ -635,23 +652,6 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) return 0; } -/* NOTE: !str is accepted for an empty string */ -static void putstr8(uint8_t **q_ptr, const char *str) -{ -uint8_t *q; -int len; - -q = *q_ptr; -if (!str) -len = 0; -else -len = strlen(str); -*q++ = len; -memcpy(q, str, len); -q += len; -*q_ptr = q; -} - static void mpegts_write_sdt(AVFormatContext *s) { MpegTSWrite *ts = s->priv_data; -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel