static SkImageDecoder* sk_libbmp_dfactory(SkStream* stream) {
static const char kBmpMagic[] = { 'B', 'M' };
- size_t len = stream->getLength();
+
char buffer[sizeof(kBmpMagic)];
- if (len > sizeof(kBmpMagic) &&
- stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
- !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) {
+ if (stream->read(buffer, sizeof(kBmpMagic)) == sizeof(kBmpMagic) &&
+ !memcmp(buffer, kBmpMagic, sizeof(kBmpMagic))) {
return SkNEW(SkBMPImageDecoder);
}
return NULL;
bool SkICOImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode)
{
- size_t length = stream->read(NULL, 0);
+ size_t length = stream->getLength();
SkAutoMalloc autoMal(length);
unsigned char* buf = (unsigned char*)autoMal.get();
if (stream->read((void*)buf, length) != length) {
args.memory_size = stream->getLength();
} else {
memset(&streamRec, 0, sizeof(streamRec));
- streamRec.size = stream->read(NULL, 0);
+ streamRec.size = stream->getLength();
streamRec.descriptor.pointer = stream;
streamRec.read = sk_stream_read;
streamRec.close = sk_stream_close;
bool SkXMLParser::parse(SkStream& input)
{
- size_t len = input.read(NULL, 0);
+ size_t len = input.getLength();
SkAutoMalloc am(len);
char* doc = (char*)am.get();
bool SkXMLParser::parse(SkStream& stream)
{
- size_t size = stream.read(NULL, 0);
+ size_t size = stream.getLength();
SkAutoMalloc buffer(size + 1);
char* buf = (char*)buffer.get();
XML_SetCharacterDataHandler(p, text_proc);
XML_SetUserData(p, &fImpl->fData);
- size_t len = fStream->read(NULL, 0);
+ size_t len = fStream->getLength();
fImpl->fBufferLen = len;
fImpl->fBuffer = sk_malloc_throw(len);
fStream->rewind();