[vlc-devel] [vlc-commits] memstream: helper for in-memory formatted output stream
Filip Roséen
filip at atch.se
Wed Sep 7 13:32:47 CEST 2016
Hi Remi,
On 16/09/07 13:04, Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Sep 7 12:41:14 2016 +0300| [27ef52ae81bf0e7127198add7ad9712567955e9f] | committer: Rémi Denis-Courmont
>
> memstream: helper for in-memory formatted output stream
>
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27ef52ae81bf0e7127198add7ad9712567955e9f
> ---
> [ ... ]
> +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;
> +}
- I guess you meant to write `if (base == NULL)`, and;
- maybe it is wise to introduce usage of `unlikely` in the file.
Best Regards, \
Filip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160907/fac3a451/attachment.html>
More information about the vlc-devel
mailing list