]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/samples/layout/paragraph.cpp
ICU-57132.0.1.tar.gz
[apple/icu.git] / icuSources / samples / layout / paragraph.cpp
index 315ca04a4b7eed44c515f5cfaadafcf332b9513d..9a92b5876d46b8678f6952fc8841b39bbb2cced1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *******************************************************************************
  *
- *   Copyright (C) 1999-2005, International Business Machines
+ *   Copyright (C) 1999-2015, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
 #include "layout/ParagraphLayout.h"
 
 #include "RenderingSurface.h"
-#include "ScriptCompositeFontInstance.h"
 
 #include "paragraph.h"
 #include "UnicodeReader.h"
-#include "FontMap.h"
 
 #define MARGIN 10
 #define LINE_GROW 32
@@ -80,7 +78,7 @@ Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns
     fLineCount(0), fLinesMax(LINE_GROW), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL),
     fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1), fParagraphLevel(UBIDI_DEFAULT_LTR)
 {
-    static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP};
+    static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000};
 
        if (LE_FAILURE(status)) {
                return;
@@ -117,6 +115,7 @@ Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns
             paragraphLayout = new ParagraphLayout(pStart, pEnd - pStart, &fr, NULL, NULL, locales, fParagraphLevel, FALSE, status);
 
             if (LE_FAILURE(status)) {
+                delete paragraphLayout;
                 break; // return? something else?
             }
 
@@ -165,8 +164,12 @@ Paragraph::~Paragraph()
         delete /*(LineInfo *)*/ fLines[line];
     }
 
+    for (le_int32 paragraph = 0; paragraph < fParagraphCount; paragraph += 1) {
+        delete fParagraphLayout[paragraph];
+    }
+
     LE_DELETE_ARRAY(fLines);
-    delete fParagraphLayout;
+    LE_DELETE_ARRAY(fParagraphLayout);
     LE_DELETE_ARRAY(fChars);
 }