changeset 825:b04673615946

don't strdup() text passed to ListItem::initWithText() Memory allocation for text is done within Textblock itself (noticed by Jeremy).
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Mon, 26 Jan 2009 22:46:07 +0100
parents 556b5972dd18
children 92b7a59b704b d513abcd4949
files dw/listitem.cc dw/listitem.hh src/html.cc test/dw_lists.cc
diffstat 4 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/dw/listitem.cc	Mon Jan 26 21:09:52 2009 +0100
+++ b/dw/listitem.cc	Mon Jan 26 22:46:07 2009 +0100
@@ -46,7 +46,7 @@
    updateValue ();
 }
 
-void ListItem::initWithText (char *text, core::style::Style *style)
+void ListItem::initWithText (const char *text, core::style::Style *style)
 {
    addText (text, style);
    addSpace (style); 
--- a/dw/listitem.hh	Mon Jan 26 21:09:52 2009 +0100
+++ b/dw/listitem.hh	Mon Jan 26 22:46:07 2009 +0100
@@ -19,7 +19,7 @@
    ~ListItem();
 
    void initWithWidget (core::Widget *widget, core::style::Style *style);
-   void initWithText (char *texty, core::style::Style *style);
+   void initWithText (const char *text, core::style::Style *style);
 };
 
 } // namespace dw
--- a/src/html.cc	Mon Jan 26 21:09:52 2009 +0100
+++ b/src/html.cc	Mon Jan 26 22:46:07 2009 +0100
@@ -2566,7 +2566,7 @@
          *list_number = 0;
       }
       numtostr((*list_number)++, buf, 16, style->listStyleType);
-      list_item->initWithText (dStrdup(buf), wordStyle);
+      list_item->initWithText (buf, wordStyle);
       list_item->addSpace (wordStyle);
       html->PrevWasSPC = true;
    } else {
--- a/test/dw_lists.cc	Mon Jan 26 21:09:52 2009 +0100
+++ b/test/dw_lists.cc	Mon Jan 26 22:46:07 2009 +0100
@@ -109,7 +109,7 @@
 
       char buf[16];
       sprintf (buf, "%d.", i);
-      listItem->initWithText (strdup (buf), wordStyle);
+      listItem->initWithText (buf, wordStyle);
 
       for(int j = 0; wordsItem[j]; j++) {
          if(j != 0)