[webkit-help] Best way to construct WTF::Vector<uint8_t> from const char array of known size

Ryosuke Niwa rniwa at webkit.org
Mon Mar 14 14:57:36 PDT 2016


On Mon, Mar 14, 2016 at 12:45 PM, Konstantin Tokarev <annulen at yandex.ru>
wrote:

>
> I have cryptographic digest function which returns result in a form
> equivalent to const char* of known size.
> Is there any way to construct WTF::Vector<uint8_t> from it without
> resorting to memcpy?
>

You mean like handing off the buffer?  I don't think Vector has such a
capability at the moment.  We normally pre-allocate Vector buffer and call
whatever function with that buffer in cases like this.  e.g.

Vector<uint8_t> digest;
digest.reserveInitialCapacity(digestSize);
cryptographicDigest(source, digest.data(), digest.size());

- R. Niwa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-help/attachments/20160314/4307bcc3/attachment.html>


More information about the webkit-help mailing list