Discussion:
[webkit-help] Best way to construct WTF::Vector<uint8_t> from const char array of known size
Konstantin Tokarev
2016-03-14 19:45:22 UTC
Permalink
Hello,

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?
--
Regards,
Konstantin
Ryosuke Niwa
2016-03-14 21:57:36 UTC
Permalink
Post by Konstantin Tokarev
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

Loading...