Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: include/ots-memory-stream.h

Issue 6410047: OTS: Adds more layout common table supports.... (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gdef.h » ('j') | src/gdef.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef OTS_MEMORY_STREAM_H_ 5 #ifndef OTS_MEMORY_STREAM_H_
6 #define OTS_MEMORY_STREAM_H_ 6 #define OTS_MEMORY_STREAM_H_
7 7
8 #include <cstring> 8 #include <cstring>
9 #include <limits> 9 #include <limits>
10 10
11 #include "opentype-sanitiser.h" 11 #include "opentype-sanitiser.h"
12 12
13 namespace ots { 13 namespace ots {
14 14
15 class MemoryStream : public OTSStream { 15 class MemoryStream : public OTSStream {
16 public: 16 public:
17 MemoryStream(void *ptr, size_t length) 17 MemoryStream(void *ptr, size_t length)
18 : ptr_(ptr), length_(length), off_(0) { 18 : ptr_(ptr), length_(length), off_(0) {
19 } 19 }
20 20
21 bool WriteRaw(const void *data, size_t length) { 21 virtual bool WriteRaw(const void *data, size_t length) {
Yusuke Sato 2011/02/04 06:12:52 Please be consistent: if you add virtual to WriteR
bashi 2011/02/07 01:17:07 Done.
22 if ((off_ + length > length_) || 22 if ((off_ + length > length_) ||
23 (length > std::numeric_limits<size_t>::max() - off_)) { 23 (length > std::numeric_limits<size_t>::max() - off_)) {
24 return false; 24 return false;
25 } 25 }
26 std::memcpy(static_cast<char*>(ptr_) + off_, data, length); 26 std::memcpy(static_cast<char*>(ptr_) + off_, data, length);
27 off_ += length; 27 off_ += length;
28 return true; 28 return true;
29 } 29 }
30 30
31 bool Seek(off_t position) { 31 bool Seek(off_t position) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 private: 96 private:
97 void* ptr_; 97 void* ptr_;
98 size_t length_; 98 size_t length_;
99 const size_t limit_; 99 const size_t limit_;
100 off_t off_; 100 off_t off_;
101 }; 101 };
102 102
103 } // namespace ots 103 } // namespace ots
104 104
105 #endif // OTS_MEMORY_STREAM_H_ 105 #endif // OTS_MEMORY_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | src/gdef.h » ('j') | src/gdef.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698