dw::Table valgrind-friendliness
On Sun, Mar 02, 2008 at 03:45:09PM +0000, Jeremy Henty wrote:
On Sun, Mar 02, 2008 at 04:14:00PM +0100, Johannes Hofmann wrote:
I think your proposed fix is fine. It's just that I don't like the wrapper methods too much in the first place and now we need even more code to support it...
I'm not particularly attached to my proposed fix, my real concern is being valgrind clean because anything that makes valgrind harder to use is bad news. My patch was just the simplest way I could see to achieve that. If there's a better way to do it then that's great!
ok, here is my proposal. It reduces the additional code in table.cc a bit. Thanks to Jeremy for testing with valgrind. Johannes diff -r 4582dc80e696 dw/table.cc --- a/dw/table.cc Sun Mar 02 13:40:23 2008 +0100 +++ b/dw/table.cc Sun Mar 02 21:21:17 2008 +0100 @@ -516,8 +516,8 @@ void Table::forceCalcCellSizes () printf(" totalWidth2 = %d curCol=%d\n", totalWidth,curCol); #endif - colWidths->setSize (numCols); - cumHeight->setSize (numRows + 1); + colWidths->setSize (numCols, 0); + cumHeight->setSize (numRows + 1, 0); rowSpanCells->setSize (0); baseline->setSize (numRows); #ifdef DBG @@ -857,7 +857,7 @@ void Table::apportion2 (int totalWidth, if (!maxAutoWidth) // no LEN_AUTO cols! return; - colWidths->setSize (colExtremes->size ()); + colWidths->setSize (colExtremes->size (), 0); if (!forceTotalWidth && maxAutoWidth < availAutoWidth) { // Enough space for the maximum table, don't widen past max. diff -r 4582dc80e696 lout/misc.hh --- a/lout/misc.hh Sun Mar 02 13:40:23 2008 +0100 +++ b/lout/misc.hh Sun Mar 02 21:21:17 2008 +0100 @@ -161,6 +161,18 @@ public: inline void setSize(int newSize) { this->num = newSize; this->resize (); } /** + * \brief Set the size explicitely and initialize new values. + * + * May be necessary before called before misc::SimpleVector::set. + */ + inline void setSize (int newSize, T t) { + int oldSize = this->num; + setSize (newSize); + for (int i = oldSize; i < newSize; i++) + set (i, t); + } + + /** * \brief Return the reference of one element. * * \sa misc::SimpleVector::get
On Sun, Mar 02, 2008 at 09:23:53PM +0100, Johannes Hofmann wrote:
On Sun, Mar 02, 2008 at 03:45:09PM +0000, Jeremy Henty wrote:
On Sun, Mar 02, 2008 at 04:14:00PM +0100, Johannes Hofmann wrote:
I think your proposed fix is fine. It's just that I don't like the wrapper methods too much in the first place and now we need even more code to support it...
I'm not particularly attached to my proposed fix, my real concern is being valgrind clean because anything that makes valgrind harder to use is bad news. My patch was just the simplest way I could see to achieve that. If there's a better way to do it then that's great!
ok, here is my proposal. It reduces the additional code in table.cc a bit. Thanks to Jeremy for testing with valgrind.
OK, committed. Please beware that this may cloak bugs. It was due to an assertion from the old code that the Table::draw() bug was found: http://lists.auriga.wearlab.de/pipermail/dillo-dev/2008-March/003837.html
Thanks to Jeremy for testing with valgrind.
Ditto. -- Cheers Jorge.-
participants (2)
-
jcid@dillo.org
-
Johannes.Hofmann@gmx.de