static void webkitScriptDialogFree(WebKitScriptDialog* dialog) { dialog->~WebKitScriptDialog(); fastFree(dialog); }
static inline void freeSegment(char* p) { fastFree(p); }
static void releaseImageData(void*, const void* data, size_t) { fastFree(const_cast<void*>(data)); }
UMat::~UMat() { release(); if( step.p != step.buf ) fastFree(step.p); }
static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, int matrixSize) { // Forms: // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array data); // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array data); // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array data); // // FIXME: need to change to accept Float32Array as well. if (args.Length() != 3) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) { V8Proxy::throwTypeError(); return notHandledByInterceptor(); } bool ok = false; WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok); bool transpose = args[1]->BooleanValue(); if (V8Float32Array::HasInstance(args[2])) { Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (matrixSize) { case 2: context->uniformMatrix2fv(location, transpose, array, ec); break; case 3: context->uniformMatrix3fv(location, transpose, array, ec); break; case 4: context->uniformMatrix4fv(location, transpose, array, ec); break; default: ASSERT_NOT_REACHED(); break; } if (ec) V8Proxy::setDOMException(ec); return v8::Undefined(); } if (args[2].IsEmpty() || !args[2]->IsArray()) { V8Proxy::throwTypeError(); return notHandledByInterceptor(); } v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[2]); uint32_t len = array->Length(); float* data = jsArrayToFloatArray(array, len); if (!data) { // FIXME: consider different / better exception type. V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } ExceptionCode ec = 0; switch (matrixSize) { case 2: context->uniformMatrix2fv(location, transpose, data, len, ec); break; case 3: context->uniformMatrix3fv(location, transpose, data, len, ec); break; case 4: context->uniformMatrix4fv(location, transpose, data, len, ec); break; default: ASSERT_NOT_REACHED(); break; } fastFree(data); if (ec) V8Proxy::setDOMException(ec); return v8::Undefined(); }
void BitVector::OutOfLineBits::destroy(OutOfLineBits* outOfLineBits) { fastFree(outOfLineBits); }
void SimpleFontData::platformInit() { if (!m_platformData.size()) { m_fontMetrics.reset(); m_avgCharWidth = 0; m_maxCharWidth = 0; return; } SkPaint paint; SkPaint::FontMetrics metrics; m_platformData.setupPaint(&paint); paint.getFontMetrics(&metrics); SkTypeface* face = paint.getTypeface(); ASSERT(face); int vdmxAscent = 0, vdmxDescent = 0; bool isVDMXValid = false; #if OS(LINUX) || OS(ANDROID) // Manually digging up VDMX metrics is only applicable when bytecode hinting // using FreeType. With GDI, the metrics will already have taken this into // account (as needed). With DirectWrite or CoreText, no bytecode hinting is // ever done. This code should be pushed into FreeType (hinted font metrics). static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X'); int pixelSize = m_platformData.size() + 0.5; if (!paint.isAutohinted() && (paint.getHinting() == SkPaint::kFull_Hinting || paint.getHinting() == SkPaint::kNormal_Hinting)) { size_t vdmxSize = face->getTableSize(vdmxTag); if (vdmxSize && vdmxSize < maxVDMXTableSize) { uint8_t* vdmxTable = (uint8_t*)fastMalloc(vdmxSize); if (vdmxTable && face->getTableData(vdmxTag, 0, vdmxSize, vdmxTable) == vdmxSize && parseVDMX(&vdmxAscent, &vdmxDescent, vdmxTable, vdmxSize, pixelSize)) isVDMXValid = true; fastFree(vdmxTable); } } #endif float ascent; float descent; // Beware those who step here: This code is designed to match Win32 font // metrics *exactly* (except the adjustment of ascent/descent on // Linux/Android). if (isVDMXValid) { ascent = vdmxAscent; descent = -vdmxDescent; } else { ascent = SkScalarRoundToInt(-metrics.fAscent); descent = SkScalarRoundToInt(metrics.fDescent); #if OS(LINUX) || OS(ANDROID) // When subpixel positioning is enabled, if the descent is rounded down, the // descent part of the glyph may be truncated when displayed in a 'overflow: // hidden' container. To avoid that, borrow 1 unit from the ascent when // possible. // FIXME: This can be removed if sub-pixel ascent/descent is supported. if (platformData().fontRenderStyle().useSubpixelPositioning && descent < SkScalarToFloat(metrics.fDescent) && ascent >= 1) { ++descent; --ascent; } #endif } m_fontMetrics.setAscent(ascent); m_fontMetrics.setDescent(descent); float xHeight; if (metrics.fXHeight) { xHeight = metrics.fXHeight; m_fontMetrics.setXHeight(xHeight); } else { xHeight = ascent * 0.56; // Best guess from Windows font metrics. m_fontMetrics.setXHeight(xHeight); m_fontMetrics.setHasXHeight(false); } float lineGap = SkScalarToFloat(metrics.fLeading); m_fontMetrics.setLineGap(lineGap); m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap)); SkScalar underlineThickness, underlinePosition; if (metrics.hasUnderlineThickness(&underlineThickness) && metrics.hasUnderlinePosition(&underlinePosition)) { m_fontMetrics.setUnderlineThickness(SkScalarToFloat(underlineThickness)); m_fontMetrics.setUnderlinePosition(SkScalarToFloat(-underlinePosition)); } if (platformData().orientation() == Vertical && !isTextOrientationFallback()) { static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a'); static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G'); size_t vheaSize = face->getTableSize(vheaTag); size_t vorgSize = face->getTableSize(vorgTag); if ((vheaSize > 0) || (vorgSize > 0)) m_hasVerticalGlyphs = true; } // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is // calculated for us, but we need to calculate m_maxCharWidth and // m_avgCharWidth in order for text entry widgets to be sized correctly. // FIXME: This seems incorrect and should probably use fMaxCharWidth as // the code path above. SkScalar xRange = metrics.fXMax - metrics.fXMin; m_maxCharWidth = SkScalarRoundToInt(xRange * SkScalarRoundToInt(m_platformData.size())); if (metrics.fAvgCharWidth) m_avgCharWidth = SkScalarRoundToInt(metrics.fAvgCharWidth); else { m_avgCharWidth = xHeight; GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); if (glyphPageZero) { static const UChar32 xChar = 'x'; const Glyph xGlyph = glyphPageZero->glyphForCharacter(xChar); if (xGlyph) { // In widthForGlyph(), xGlyph will be compared with // m_zeroWidthSpaceGlyph, which isn't initialized yet here. // Initialize it with zero to make sure widthForGlyph() returns // the right width. m_zeroWidthSpaceGlyph = 0; m_avgCharWidth = widthForGlyph(xGlyph); } } } if (int unitsPerEm = face->getUnitsPerEm()) m_fontMetrics.setUnitsPerEm(unitsPerEm); }
static inline void deleteUCharVector(const UChar* p) { fastFree(const_cast<UChar*>(p)); }
void StringImpl::operator delete(void* address) { fastFree(address); }
ImageBuffer::~ImageBuffer() { fastFree(m_data); }
void WeakBlock::destroy(Heap& heap, WeakBlock* block) { block->~WeakBlock(); fastFree(block); heap.didFreeBlock(WeakBlock::blockSize); }
String TextCodecGtk::decode(const char* bytes, size_t length, bool flush, bool stopOnError, bool& sawError) { // Get a converter for the passed-in encoding. if (m_iconvDecoder == reinterpret_cast<GIConv>(-1)) { createIConvDecoder(); ASSERT(m_iconvDecoder != reinterpret_cast<GIConv>(-1)); if (m_iconvDecoder == reinterpret_cast<GIConv>(-1)) { LOG_ERROR("Error creating IConv encoder even though encoding was in table."); return String(); } } size_t countWritten, countRead, conversionLength; const char* conversionBytes; char* prefixedBytes = 0; if (m_numBufferedBytes) { conversionLength = length + m_numBufferedBytes; prefixedBytes = static_cast<char*>(fastMalloc(conversionLength)); memcpy(prefixedBytes, m_bufferedBytes, m_numBufferedBytes); memcpy(prefixedBytes + m_numBufferedBytes, bytes, length); conversionBytes = prefixedBytes; // all buffered bytes are consumed now m_numBufferedBytes = 0; } else { // no previously buffered partial data, // just convert the data that was passed in conversionBytes = bytes; conversionLength = length; } GOwnPtr<GError> err; GOwnPtr<UChar> buffer; buffer.outPtr() = reinterpret_cast<UChar*>(g_convert_with_iconv(conversionBytes, conversionLength, m_iconvDecoder, &countRead, &countWritten, &err.outPtr())); if (err) { LOG_ERROR("GIConv conversion error, Code %d: \"%s\"", err->code, err->message); m_numBufferedBytes = 0; // reset state for subsequent calls to decode fastFree(prefixedBytes); sawError = true; return String(); } // Partial input at the end of the string may not result in an error being raised. // From the gnome library documentation on g_convert_with_iconv: // "Even if the conversion was successful, this may be less than len if there were partial characters at the end of the input." // That's why we need to compare conversionLength against countRead m_numBufferedBytes = conversionLength - countRead; if (m_numBufferedBytes > 0) { if (flush) { LOG_ERROR("Partial bytes at end of input while flush requested."); m_numBufferedBytes = 0; // reset state for subsequent calls to decode fastFree(prefixedBytes); sawError = true; return String(); } memcpy(m_bufferedBytes, conversionBytes + countRead, m_numBufferedBytes); } fastFree(prefixedBytes); Vector<UChar> result; result.append(buffer.get(), countWritten / sizeof(UChar)); return String::adopt(result); }
PassOwnPtr<GenericCompressedData> GenericCompressedData::create(const uint8_t* data, size_t dataLength) { enum { MinimumSize = sizeof(GenericCompressedData) * 8 }; if (!data || dataLength < MinimumSize) return nullptr; z_stream stream; memset(&stream, 0, sizeof(stream)); stream.zalloc = zAlloc; stream.zfree = zFree; stream.data_type = Z_BINARY; stream.opaque = Z_NULL; stream.avail_in = dataLength; stream.next_in = const_cast<uint8_t*>(data); size_t currentOffset = OBJECT_OFFSETOF(GenericCompressedData, m_data); size_t currentCapacity = fastMallocGoodSize(MinimumSize); Bytef* compressedData = static_cast<Bytef*>(fastMalloc(currentCapacity)); memset(compressedData, 0, sizeof(GenericCompressedData)); stream.next_out = compressedData + currentOffset; stream.avail_out = currentCapacity - currentOffset; deflateInit(&stream, Z_BEST_COMPRESSION); while (true) { int deflateResult = deflate(&stream, Z_FINISH); if (deflateResult == Z_OK || !stream.avail_out) { size_t newCapacity = 0; currentCapacity -= stream.avail_out; if (!stream.avail_in) newCapacity = currentCapacity + 8; else { // Determine average capacity size_t compressedContent = stream.next_in - data; double expectedSize = static_cast<double>(dataLength) * compressedContent / currentCapacity; // Expand capacity by at least 8 bytes so we're always growing, and to // compensate for any exaggerated ideas of how effectively we'll compress // data in the future. newCapacity = std::max(static_cast<size_t>(expectedSize + 8), currentCapacity + 8); } newCapacity = fastMallocGoodSize(newCapacity); if (newCapacity >= dataLength) goto fail; compressedData = static_cast<Bytef*>(fastRealloc(compressedData, newCapacity)); currentOffset = currentCapacity - stream.avail_out; stream.next_out = compressedData + currentOffset; stream.avail_out = newCapacity - currentCapacity; currentCapacity = newCapacity; continue; } if (deflateResult == Z_STREAM_END) { ASSERT(!stream.avail_in); break; } ASSERT_NOT_REACHED(); fail: deflateEnd(&stream); fastFree(compressedData); return nullptr; } deflateEnd(&stream); static int64_t totalCompressed = 0; static int64_t totalInput = 0; totalCompressed += currentCapacity; totalInput += dataLength; GenericCompressedData* result = new (compressedData) GenericCompressedData(dataLength, stream.total_out); return adoptPtr(result); }
static void zFree(void*, void* data) { fastFree(data); }
void operator delete[](void* p) { fastMallocMatchValidateFree(p, WTF::Internal::AllocTypeClassNewArray); fastFree(p); // We don't need to check for a null pointer; the compiler does this. }
JSGlobalData::~JSGlobalData() { // By the time this is destroyed, heap.destroy() must already have been called. delete interpreter; #ifndef NDEBUG // Zeroing out to make the behavior more predictable when someone attempts to use a deleted instance. interpreter = 0; #endif arrayPrototypeTable->deleteTable(); arrayConstructorTable->deleteTable(); booleanPrototypeTable->deleteTable(); dateTable->deleteTable(); dateConstructorTable->deleteTable(); errorPrototypeTable->deleteTable(); globalObjectTable->deleteTable(); jsonTable->deleteTable(); mathTable->deleteTable(); numberConstructorTable->deleteTable(); numberPrototypeTable->deleteTable(); objectConstructorTable->deleteTable(); objectPrototypeTable->deleteTable(); regExpTable->deleteTable(); regExpConstructorTable->deleteTable(); regExpPrototypeTable->deleteTable(); stringTable->deleteTable(); stringConstructorTable->deleteTable(); fastDelete(const_cast<HashTable*>(arrayConstructorTable)); fastDelete(const_cast<HashTable*>(arrayPrototypeTable)); fastDelete(const_cast<HashTable*>(booleanPrototypeTable)); fastDelete(const_cast<HashTable*>(dateTable)); fastDelete(const_cast<HashTable*>(dateConstructorTable)); fastDelete(const_cast<HashTable*>(errorPrototypeTable)); fastDelete(const_cast<HashTable*>(globalObjectTable)); fastDelete(const_cast<HashTable*>(jsonTable)); fastDelete(const_cast<HashTable*>(mathTable)); fastDelete(const_cast<HashTable*>(numberConstructorTable)); fastDelete(const_cast<HashTable*>(numberPrototypeTable)); fastDelete(const_cast<HashTable*>(objectConstructorTable)); fastDelete(const_cast<HashTable*>(objectPrototypeTable)); fastDelete(const_cast<HashTable*>(regExpTable)); fastDelete(const_cast<HashTable*>(regExpConstructorTable)); fastDelete(const_cast<HashTable*>(regExpPrototypeTable)); fastDelete(const_cast<HashTable*>(stringTable)); fastDelete(const_cast<HashTable*>(stringConstructorTable)); opaqueJSClassData.clear(); delete emptyList; delete propertyNames; if (globalDataType != Default) deleteIdentifierTable(identifierTable); delete clientData; delete m_regExpCache; #if ENABLE(REGEXP_TRACING) delete m_rtTraceList; #endif #if ENABLE(DFG_JIT) for (unsigned i = 0; i < scratchBuffers.size(); ++i) fastFree(scratchBuffers[i]); #endif }
~TextRunWalker() { fastFree(m_item.font); deleteGlyphArrays(); delete[] m_item.log_clusters; }
ShareableBitmap::~ShareableBitmap() { if (!isBackedBySharedMemory()) fastFree(m_data); }
ShadowChicken::~ShadowChicken() { fastFree(m_log); }
static void gst_allocator_fast_malloc_free(GstAllocator*, GstMemory* mem) { ASSERT(G_TYPE_CHECK_INSTANCE_TYPE(allocator, gst_allocator_fast_malloc_get_type())); fastFree(mem); }
void deallocate(pointer p, size_type) { fastFree(p); }
void MarkStack::releaseStack(void* addr, size_t size) { return fastFree(addr); }
static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, FunctionToCall functionToCall) { // Forms: // * glUniform1iv(GLUniformLocation location, Array data); // * glUniform1iv(GLUniformLocation location, Int32Array data); // * glUniform2iv(GLUniformLocation location, Array data); // * glUniform2iv(GLUniformLocation location, Int32Array data); // * glUniform3iv(GLUniformLocation location, Array data); // * glUniform3iv(GLUniformLocation location, Int32Array data); // * glUniform4iv(GLUniformLocation location, Array data); // * glUniform4iv(GLUniformLocation location, Int32Array data); if (args.Length() != 2) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0])) { V8Proxy::throwTypeError(); return notHandledByInterceptor(); } bool ok = false; WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok); if (V8Int32Array::HasInstance(args[1])) { Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (functionToCall) { case kUniform1v: context->uniform1iv(location, array, ec); break; case kUniform2v: context->uniform2iv(location, array, ec); break; case kUniform3v: context->uniform3iv(location, array, ec); break; case kUniform4v: context->uniform4iv(location, array, ec); break; default: ASSERT_NOT_REACHED(); break; } if (ec) V8Proxy::setDOMException(ec); return v8::Undefined(); } if (args[1].IsEmpty() || !args[1]->IsArray()) { V8Proxy::throwTypeError(); return notHandledByInterceptor(); } v8::Handle<v8::Array> array = v8::Local<v8::Array>::Cast(args[1]); uint32_t len = array->Length(); int* data = jsArrayToIntArray(array, len); if (!data) { // FIXME: consider different / better exception type. V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } ExceptionCode ec = 0; switch (functionToCall) { case kUniform1v: context->uniform1iv(location, data, len, ec); break; case kUniform2v: context->uniform2iv(location, data, len, ec); break; case kUniform3v: context->uniform3iv(location, data, len, ec); break; case kUniform4v: context->uniform4iv(location, data, len, ec); break; default: ASSERT_NOT_REACHED(); break; } fastFree(data); if (ec) V8Proxy::setDOMException(ec); return v8::Undefined(); }
JSGlobalData::~JSGlobalData() { ASSERT(!m_apiLock.currentThreadIsHoldingLock()); heap.activityCallback()->didStartVMShutdown(); heap.sweeper()->didStartVMShutdown(); heap.lastChanceToFinalize(); delete interpreter; #ifndef NDEBUG interpreter = reinterpret_cast<Interpreter*>(0xbbadbeef); #endif arrayPrototypeTable->deleteTable(); arrayConstructorTable->deleteTable(); booleanPrototypeTable->deleteTable(); dateTable->deleteTable(); dateConstructorTable->deleteTable(); errorPrototypeTable->deleteTable(); globalObjectTable->deleteTable(); jsonTable->deleteTable(); mathTable->deleteTable(); numberConstructorTable->deleteTable(); numberPrototypeTable->deleteTable(); objectConstructorTable->deleteTable(); objectPrototypeTable->deleteTable(); privateNamePrototypeTable->deleteTable(); regExpTable->deleteTable(); regExpConstructorTable->deleteTable(); regExpPrototypeTable->deleteTable(); stringTable->deleteTable(); stringConstructorTable->deleteTable(); fastDelete(const_cast<HashTable*>(arrayConstructorTable)); fastDelete(const_cast<HashTable*>(arrayPrototypeTable)); fastDelete(const_cast<HashTable*>(booleanPrototypeTable)); fastDelete(const_cast<HashTable*>(dateTable)); fastDelete(const_cast<HashTable*>(dateConstructorTable)); fastDelete(const_cast<HashTable*>(errorPrototypeTable)); fastDelete(const_cast<HashTable*>(globalObjectTable)); fastDelete(const_cast<HashTable*>(jsonTable)); fastDelete(const_cast<HashTable*>(mathTable)); fastDelete(const_cast<HashTable*>(numberConstructorTable)); fastDelete(const_cast<HashTable*>(numberPrototypeTable)); fastDelete(const_cast<HashTable*>(objectConstructorTable)); fastDelete(const_cast<HashTable*>(objectPrototypeTable)); fastDelete(const_cast<HashTable*>(privateNamePrototypeTable)); fastDelete(const_cast<HashTable*>(regExpTable)); fastDelete(const_cast<HashTable*>(regExpConstructorTable)); fastDelete(const_cast<HashTable*>(regExpPrototypeTable)); fastDelete(const_cast<HashTable*>(stringTable)); fastDelete(const_cast<HashTable*>(stringConstructorTable)); opaqueJSClassData.clear(); delete emptyList; delete propertyNames; if (globalDataType != Default) deleteIdentifierTable(identifierTable); delete clientData; delete m_regExpCache; #if ENABLE(REGEXP_TRACING) delete m_rtTraceList; #endif #if ENABLE(DFG_JIT) for (unsigned i = 0; i < scratchBuffers.size(); ++i) fastFree(scratchBuffers[i]); #endif }
void SimpleFontData::platformInit() { if (!m_platformData.size()) { m_fontMetrics.reset(); m_avgCharWidth = 0; m_maxCharWidth = 0; return; } SkPaint paint; SkPaint::FontMetrics metrics; m_platformData.setupPaint(&paint); paint.getFontMetrics(&metrics); const SkFontID fontID = m_platformData.uniqueID(); static const uint32_t vdmxTag = SkSetFourByteTag('V', 'D', 'M', 'X'); int pixelSize = m_platformData.size() + 0.5; int vdmxAscent, vdmxDescent; bool isVDMXValid = false; size_t vdmxSize = SkFontHost::GetTableSize(fontID, vdmxTag); if (vdmxSize && vdmxSize < maxVDMXTableSize) { uint8_t* vdmxTable = (uint8_t*) fastMalloc(vdmxSize); if (vdmxTable && SkFontHost::GetTableData(fontID, vdmxTag, 0, vdmxSize, vdmxTable) == vdmxSize && parseVDMX(&vdmxAscent, &vdmxDescent, vdmxTable, vdmxSize, pixelSize)) isVDMXValid = true; fastFree(vdmxTable); } float ascent; float descent; // Beware those who step here: This code is designed to match Win32 font // metrics *exactly*. if (isVDMXValid) { ascent = vdmxAscent; descent = -vdmxDescent; } else { SkScalar height = -metrics.fAscent + metrics.fDescent + metrics.fLeading; ascent = SkScalarRound(-metrics.fAscent); descent = SkScalarRound(height) - ascent; } m_fontMetrics.setAscent(ascent); m_fontMetrics.setDescent(descent); float xHeight; if (metrics.fXHeight) xHeight = metrics.fXHeight; else { // hack taken from the Windows port xHeight = ascent * 0.56f; } float lineGap = SkScalarToFloat(metrics.fLeading); m_fontMetrics.setLineGap(lineGap); m_fontMetrics.setXHeight(xHeight); m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap)); if (platformData().orientation() == Vertical && !isTextOrientationFallback()) { static const uint32_t vheaTag = SkSetFourByteTag('v', 'h', 'e', 'a'); static const uint32_t vorgTag = SkSetFourByteTag('V', 'O', 'R', 'G'); size_t vheaSize = SkFontHost::GetTableSize(fontID, vheaTag); size_t vorgSize = SkFontHost::GetTableSize(fontID, vorgTag); if ((vheaSize > 0) || (vorgSize > 0)) m_hasVerticalGlyphs = true; } // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is // calculated for us, but we need to calculate m_maxCharWidth and // m_avgCharWidth in order for text entry widgets to be sized correctly. SkScalar xRange = metrics.fXMax - metrics.fXMin; m_maxCharWidth = SkScalarRound(xRange * SkScalarRound(m_platformData.size())); if (metrics.fAvgCharWidth) m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth); else { m_avgCharWidth = xHeight; GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); if (glyphPageZero) { static const UChar32 x_char = 'x'; const Glyph xGlyph = glyphPageZero->glyphDataForCharacter(x_char).glyph; if (xGlyph) m_avgCharWidth = widthForGlyph(xGlyph); } } }
DataSection::~DataSection() { fastFree(m_data); }
String WebCore::signedPublicKeyAndChallengeString(unsigned index, const String& challenge, const KURL& url) { String keyString; HCRYPTPROV hContext = 0; HCRYPTKEY hKey = 0; PCERT_PUBLIC_KEY_INFO pPubInfo = 0; // Try to delete it if it exists already CryptAcquireContext(&hContext, _T("keygen_container"), MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_DELETEKEYSET); do { if (!CryptAcquireContext(&hContext, _T("keygen_container"), MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_NEWKEYSET)) break; DWORD dwPubInfoLength = 0; if (!CryptGenKey(hContext, AT_KEYEXCHANGE, 0, &hKey) || !CryptExportPublicKeyInfo(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, 0, &dwPubInfoLength)) break; // Use malloc instead of new, because malloc guarantees to return a pointer aligned for all data types. pPubInfo = reinterpret_cast<PCERT_PUBLIC_KEY_INFO>(fastMalloc(dwPubInfoLength)); if (!CryptExportPublicKeyInfo(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, pPubInfo, &dwPubInfoLength)) break; CERT_KEYGEN_REQUEST_INFO requestInfo = { 0 }; requestInfo.dwVersion = CERT_KEYGEN_REQUEST_V1; requestInfo.pwszChallengeString = L""; requestInfo.SubjectPublicKeyInfo = *pPubInfo; String localChallenge = challenge; // Windows API won't write to our buffer, although it's not declared with const. requestInfo.pwszChallengeString = const_cast<wchar_t*>(localChallenge.charactersWithNullTermination()); CRYPT_ALGORITHM_IDENTIFIER signAlgo = { 0 }; signAlgo.pszObjId = szOID_RSA_SHA1RSA; DWORD dwEncodedLength; if (!CryptSignAndEncodeCertificate(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, X509_KEYGEN_REQUEST_TO_BE_SIGNED, &requestInfo, &signAlgo, 0, 0, &dwEncodedLength)) break; Vector<char> binary(dwEncodedLength); if (!CryptSignAndEncodeCertificate(hContext, AT_KEYEXCHANGE, X509_ASN_ENCODING, X509_KEYGEN_REQUEST_TO_BE_SIGNED, &requestInfo, &signAlgo, 0, reinterpret_cast<LPBYTE>(binary.data()), &dwEncodedLength)) break; Vector<char> base64; base64Encode(binary, base64); keyString = String(base64.data(), base64.size()); } while(0); if (pPubInfo) fastFree(pPubInfo); if (hKey) CryptDestroyKey(hKey); if (hContext) CryptReleaseContext(hContext, 0); return keyString; }
WebSocketChannel::~WebSocketChannel() { fastFree(m_buffer); }
ResourceHandleInternal::~ResourceHandleInternal() { fastFree(m_url); if (m_customHeaders) curl_slist_free_all(m_customHeaders); }
VM::~VM() { // Clear this first to ensure that nobody tries to remove themselves from it. m_perBytecodeProfiler.clear(); ASSERT(m_apiLock->currentThreadIsHoldingLock()); m_apiLock->willDestroyVM(this); heap.lastChanceToFinalize(); delete interpreter; #ifndef NDEBUG interpreter = reinterpret_cast<Interpreter*>(0xbbadbeef); #endif arrayPrototypeTable->deleteTable(); arrayConstructorTable->deleteTable(); booleanPrototypeTable->deleteTable(); dateTable->deleteTable(); dateConstructorTable->deleteTable(); errorPrototypeTable->deleteTable(); globalObjectTable->deleteTable(); jsonTable->deleteTable(); mathTable->deleteTable(); numberConstructorTable->deleteTable(); numberPrototypeTable->deleteTable(); objectConstructorTable->deleteTable(); privateNamePrototypeTable->deleteTable(); regExpTable->deleteTable(); regExpConstructorTable->deleteTable(); regExpPrototypeTable->deleteTable(); stringConstructorTable->deleteTable(); fastDelete(const_cast<HashTable*>(arrayConstructorTable)); fastDelete(const_cast<HashTable*>(arrayPrototypeTable)); fastDelete(const_cast<HashTable*>(booleanPrototypeTable)); fastDelete(const_cast<HashTable*>(dateTable)); fastDelete(const_cast<HashTable*>(dateConstructorTable)); fastDelete(const_cast<HashTable*>(errorPrototypeTable)); fastDelete(const_cast<HashTable*>(globalObjectTable)); fastDelete(const_cast<HashTable*>(jsonTable)); fastDelete(const_cast<HashTable*>(mathTable)); fastDelete(const_cast<HashTable*>(numberConstructorTable)); fastDelete(const_cast<HashTable*>(numberPrototypeTable)); fastDelete(const_cast<HashTable*>(objectConstructorTable)); fastDelete(const_cast<HashTable*>(privateNamePrototypeTable)); fastDelete(const_cast<HashTable*>(regExpTable)); fastDelete(const_cast<HashTable*>(regExpConstructorTable)); fastDelete(const_cast<HashTable*>(regExpPrototypeTable)); fastDelete(const_cast<HashTable*>(stringConstructorTable)); delete emptyList; delete propertyNames; if (vmType != Default) deleteIdentifierTable(identifierTable); delete clientData; delete m_regExpCache; #if ENABLE(REGEXP_TRACING) delete m_rtTraceList; #endif #if ENABLE(DFG_JIT) for (unsigned i = 0; i < scratchBuffers.size(); ++i) fastFree(scratchBuffers[i]); #endif }