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

Side by Side Diff: src/ports/SkFontConfigInterface_direct.cpp

Issue 19466004: Make the copy of fontconfig font names before freeing their memory. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009 Google Inc. 2 * Copyright 2009 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */
9 9
10 #include <string> 10 #include <string>
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 return true; 556 return true;
557 } 557 }
558 } 558 }
559 return false; 559 return false;
560 } 560 }
561 561
562 SkDataTable* SkFontConfigInterfaceDirect::getFamilyNames() { 562 SkDataTable* SkFontConfigInterfaceDirect::getFamilyNames() {
563 SkAutoMutexAcquire ac(mutex_); 563 SkAutoMutexAcquire ac(mutex_);
564 564
565 FcPattern* pat = FcPatternCreate(); 565 FcPattern* pat = FcPatternCreate();
566 FcObjectSet* os = FcObjectSetBuild (FC_FAMILY, (char *) 0); 566 SkAutoTCallVProc<FcPattern, FcPatternDestroy> autoDestroyPat(pat);
567 if (NULL == pat) {
568 return NULL;
569 }
570
571 FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, (char *)0);
572 SkAutoTCallVProc<FcObjectSet, FcObjectSetDestroy> autoDestroyOs(os);
567 if (NULL == os) { 573 if (NULL == os) {
568 return NULL; 574 return NULL;
569 } 575 }
576
570 FcFontSet* fs = FcFontList(NULL, pat, os); 577 FcFontSet* fs = FcFontList(NULL, pat, os);
578 SkAutoTCallVProc<FcFontSet, FcFontSetDestroy> autoDestroyFs(fs);
571 if (NULL == fs) { 579 if (NULL == fs) {
572 FcObjectSetDestroy(os);
573 return NULL; 580 return NULL;
574 } 581 }
575 582
576 SkTDArray<const char*> names; 583 SkTDArray<const char*> names;
577 SkTDArray<size_t> sizes; 584 SkTDArray<size_t> sizes;
578 for (int i = 0; i < fs->nfont; ++i) { 585 for (int i = 0; i < fs->nfont; ++i) {
579 FcPattern* match = fs->fonts[i]; 586 FcPattern* match = fs->fonts[i];
580 const char* famName = get_name(match, FC_FAMILY); 587 const char* famName = get_name(match, FC_FAMILY);
581 if (famName && !find_name(names, famName)) { 588 if (famName && !find_name(names, famName)) {
582 *names.append() = famName; 589 *names.append() = famName;
583 *sizes.append() = strlen(famName) + 1; 590 *sizes.append() = strlen(famName) + 1;
584 } 591 }
585 } 592 }
586 593
587 FcFontSetDestroy(fs);
588 FcObjectSetDestroy(os);
589 FcPatternDestroy(pat);
590
591 return SkDataTable::NewCopyArrays((const void*const*)names.begin(), 594 return SkDataTable::NewCopyArrays((const void*const*)names.begin(),
592 sizes.begin(), names.count()); 595 sizes.begin(), names.count());
593 } 596 }
594 597
595 bool SkFontConfigInterfaceDirect::matchFamilySet(const char inFamilyName[], 598 bool SkFontConfigInterfaceDirect::matchFamilySet(const char inFamilyName[],
596 SkString* outFamilyName, 599 SkString* outFamilyName,
597 SkTArray<FontIdentity>* ids) { 600 SkTArray<FontIdentity>* ids) {
598 SkAutoMutexAcquire ac(mutex_); 601 SkAutoMutexAcquire ac(mutex_);
599 602
600 #if 0 603 #if 0
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 *trimmedMatches.append() = match[i]; 717 *trimmedMatches.append() = match[i];
715 } 718 }
716 } 719 }
717 720
718 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, 721 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC,
719 (trimmedMatches.begin(), 722 (trimmedMatches.begin(),
720 trimmedMatches.count())); 723 trimmedMatches.count()));
721 #endif 724 #endif
722 return false; 725 return false;
723 } 726 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698