Merge pull request #74 from rsheeter/master

Avoid shadowing
This commit is contained in:
rsheeter
2017-02-23 10:45:24 -08:00
committed by GitHub
3 changed files with 24 additions and 22 deletions
+5 -5
View File
@@ -65,8 +65,8 @@ inline bool Failure(const char *f, int l, const char *fn) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
class Buffer { class Buffer {
public: public:
Buffer(const uint8_t *buffer, size_t len) Buffer(const uint8_t *data, size_t len)
: buffer_(buffer), : buffer_(data),
length_(len), length_(len),
offset_(0) { } offset_(0) { }
@@ -74,7 +74,7 @@ class Buffer {
return Read(NULL, n_bytes); return Read(NULL, n_bytes);
} }
bool Read(uint8_t *buffer, size_t n_bytes) { bool Read(uint8_t *data, size_t n_bytes) {
if (n_bytes > 1024 * 1024 * 1024) { if (n_bytes > 1024 * 1024 * 1024) {
return FONT_COMPRESSION_FAILURE(); return FONT_COMPRESSION_FAILURE();
} }
@@ -82,8 +82,8 @@ class Buffer {
(offset_ > length_ - n_bytes)) { (offset_ > length_ - n_bytes)) {
return FONT_COMPRESSION_FAILURE(); return FONT_COMPRESSION_FAILURE();
} }
if (buffer) { if (data) {
std::memcpy(buffer, buffer_ + offset_, n_bytes); std::memcpy(data, buffer_ + offset_, n_bytes);
} }
offset_ += n_bytes; offset_ += n_bytes;
return true; return true;
+2
View File
@@ -118,6 +118,7 @@ bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) {
// Read the run-length coded flags. // Read the run-length coded flags.
std::vector<std::vector<uint8_t> > flags(num_contours); std::vector<std::vector<uint8_t> > flags(num_contours);
{
uint8_t flag = 0; uint8_t flag = 0;
uint8_t flag_repeat = 0; uint8_t flag_repeat = 0;
for (int i = 0; i < num_contours; ++i) { for (int i = 0; i < num_contours; ++i) {
@@ -139,6 +140,7 @@ bool ReadGlyph(const uint8_t* data, size_t len, Glyph* glyph) {
glyph->contours[i][j].on_curve = flag & kFLAG_ONCURVE; glyph->contours[i][j].on_curve = flag & kFLAG_ONCURVE;
} }
} }
}
// Read the x coordinates. // Read the x coordinates.
int prev_x = 0; int prev_x = 0;
+2 -2
View File
@@ -49,8 +49,8 @@ void Write255UShort(std::vector<uint8_t>* out, int value) {
void Store255UShort(int val, size_t* offset, uint8_t* dst) { void Store255UShort(int val, size_t* offset, uint8_t* dst) {
std::vector<uint8_t> packed; std::vector<uint8_t> packed;
Write255UShort(&packed, val); Write255UShort(&packed, val);
for (uint8_t val : packed) { for (uint8_t packed_byte : packed) {
dst[(*offset)++] = val; dst[(*offset)++] = packed_byte;
} }
} }