[HarfBuzz] harfbuzz: Branch 'master'

Simon Hausmann hausmann at kemper.freedesktop.org
Wed Jan 21 02:15:38 PST 2009


 src/harfbuzz-external.h            |    1 +
 src/harfbuzz-thai.c                |    5 ++---
 tests/linebreaking/harfbuzz-qt.cpp |    8 +++++++-
 3 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 608ccc0b6a5c3aca27919260f7a79142895afb8e
Author: Simon Hausmann <simon.hausmann at nokia.com>
Date:   Wed Jan 21 11:14:22 2009 +0100

    Make it possible to keep the allocation and de-allocation of the text codec result in the same place.

diff --git a/src/harfbuzz-external.h b/src/harfbuzz-external.h
index 29c4631..760749b 100644
--- a/src/harfbuzz-external.h
+++ b/src/harfbuzz-external.h
@@ -150,6 +150,7 @@ void *HB_Library_Resolve(const char *library, const char *symbol);
 
 void *HB_TextCodecForMib(int mib);
 char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb_uint32 length, hb_uint32 *outputLength);
+void HB_TextCodec_FreeResult(char *);
 
 HB_END_HEADER
 
diff --git a/src/harfbuzz-thai.c b/src/harfbuzz-thai.c
index 6279e15..1d1aa2f 100644
--- a/src/harfbuzz-thai.c
+++ b/src/harfbuzz-thai.c
@@ -33,7 +33,6 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri
     typedef int (*th_brk_def)(const char*, int[], int);
     static void *thaiCodec = 0;
     static th_brk_def th_brk = 0;
-    hb_uint32 cstrLength = 0;
     char *cstr = 0;
     int brp[128];
     int *break_positions = brp;
@@ -53,7 +52,7 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri
     if (!th_brk)
         return;
 
-    cstr = HB_TextCodec_ConvertFromUnicode(thaiCodec, string, len, &cstrLength);
+    cstr = HB_TextCodec_ConvertFromUnicode(thaiCodec, string, len, 0);
     if (!cstr)
         return;
 
@@ -75,7 +74,7 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri
     if (break_positions != brp)
         free(break_positions);
 
-    free(cstr);
+    HB_TextCodec_FreeResult(cstr);
 }
 
 
diff --git a/tests/linebreaking/harfbuzz-qt.cpp b/tests/linebreaking/harfbuzz-qt.cpp
index 71d8439..305a1ba 100644
--- a/tests/linebreaking/harfbuzz-qt.cpp
+++ b/tests/linebreaking/harfbuzz-qt.cpp
@@ -93,7 +93,13 @@ char *HB_TextCodec_ConvertFromUnicode(void *codec, const HB_UChar16 *unicode, hb
     // ### suboptimal
     char *output = (char *)malloc(data.length() + 1);
     memcpy(output, data.constData(), data.length() + 1);
-    *outputLength = data.length();
+    if (outputLength)
+        *outputLength = data.length();
     return output;
 }
 
+void HB_TextCodec_FreeResult(char *string)
+{
+    free(string);
+}
+



More information about the HarfBuzz mailing list