diff options
Diffstat (limited to 'Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp')
-rw-r--r-- | Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp b/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp index d0fc55ddf50..87ebc39e23d 100644 --- a/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp +++ b/Build/source/libs/graphite2/graphite2-src/src/FeatureMap.cpp @@ -73,7 +73,7 @@ FeatureRef::FeatureRef(const Face & face, unsigned short & bits_offset, uint32 max_val, uint32 name, uint16 uiName, uint16 flags, FeatureSetting *settings, uint16 num_set) throw() -: m_pFace(&face), +: m_face(face), m_nameValues(settings), m_mask(mask_over_val(max_val)), m_max(max_val), @@ -120,7 +120,7 @@ bool FeatureMap::readFeats(const Face & face) return false; } - m_feats = new FeatureRef [m_numFeats]; + m_feats = grzeroalloc<FeatureRef>(m_numFeats); uint16 * const defVals = gralloc<uint16>(m_numFeats); if (!defVals || !m_feats) return false; unsigned short bits = 0; //to cause overflow on first Feature @@ -176,9 +176,9 @@ bool FeatureMap::readFeats(const Face & face) for (int i = 0; i < m_numFeats; ++i) { m_feats[i].applyValToFeature(defVals[i], m_defaultFeatures); - m_pNamedFeats[i] = m_feats+i; + m_pNamedFeats[i] = m_feats[i]; } - + free(defVals); qsort(m_pNamedFeats, m_numFeats, sizeof(NameAndFeatureRef), &cmpNameAndFeatures); @@ -267,13 +267,13 @@ const FeatureRef *FeatureMap::findFeatureRef(uint32 name) const } bool FeatureRef::applyValToFeature(uint32 val, Features & pDest) const -{ - if (val>maxVal() || !m_pFace) +{ + if (val>maxVal()) return false; if (pDest.m_pMap==NULL) - pDest.m_pMap = &m_pFace->theSill().theFeatureMap(); + pDest.m_pMap = &m_face.theSill().theFeatureMap(); else - if (pDest.m_pMap!=&m_pFace->theSill().theFeatureMap()) + if (pDest.m_pMap!=&m_face.theSill().theFeatureMap()) return false; //incompatible if (m_index >= pDest.size()) pDest.resize(m_index+1); @@ -283,11 +283,9 @@ bool FeatureRef::applyValToFeature(uint32 val, Features & pDest) const } uint32 FeatureRef::getFeatureVal(const Features& feats) const -{ - if (m_index < feats.size() && &m_pFace->theSill().theFeatureMap()==feats.m_pMap) - return (feats[m_index] & m_mask) >> m_bits; +{ + if (m_index < feats.size() && &m_face.theSill().theFeatureMap()==feats.m_pMap) + return (feats[m_index] & m_mask) >> m_bits; else return 0; } - - |