<p>Hi Remi,</p>
<p>On 16/09/07 13:04, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> vlc | branch: master | Rémi Denis-Courmont <remi@remlab.net> | Wed Sep 7 12:41:14 2016 +0300| [27ef52ae81bf0e7127198add7ad9712567955e9f] | committer: Rémi Denis-Courmont
memstream: helper for in-memory formatted output stream</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<h3 id="httpgit.videolan.orggitweb.cgivlc.gitacommith27ef52ae81bf0e7127198add7ad9712567955e9f">http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27ef52ae81bf0e7127198add7ad9712567955e9f</h3>
</blockquote>
</blockquote>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> [ ... ]</code></pre>
</blockquote>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> +size_t vlc_memstream_write(struct vlc_memstream *ms, const void *ptr,
+ size_t len)
+{
+ char *base = realloc(ms->ptr, ms->length + len + 1u);
+ if (ptr == NULL)
+ goto error;
+
+ memcpy(base + ms->length, ptr, len);
+ ms->ptr = base;
+ ms->length += len;
+ base[ms->length] = '\0';
+ return len;
+
+error:
+ ms->error = EOF;
+ return EOF;
+}</code></pre>
</blockquote>
<ul>
<li>I guess you meant to write <code>if (base == NULL)</code>, and;</li>
<li>maybe it is wise to introduce usage of <code>unlikely</code> in the file.</li>
</ul>
<p>Best Regards,<br />
Filip</p>