[Libreoffice-commits] .: 2 commits - vcl/Library_vclplug_gen.mk vcl/unx
Caolán McNamara
caolan at kemper.freedesktop.org
Sun May 6 02:28:41 PDT 2012
vcl/Library_vclplug_gen.mk | 7 +++++++
vcl/unx/generic/gdi/salbmp.cxx | 37 ++++++++++++++++++++++++++++++++++---
2 files changed, 41 insertions(+), 3 deletions(-)
New commits:
commit 810ab680c60e21660cbb1bfa1893ee6321bfa771
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat May 5 23:52:18 2012 +0100
valgrind: silence annoying conditional jump warnings from dead scanline space
Change-Id: I46f3d61ff85886c44849c22bfda4a3628041d6dd
diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk
index c9c9bbe..31df6c2 100644
--- a/vcl/Library_vclplug_gen.mk
+++ b/vcl/Library_vclplug_gen.mk
@@ -132,6 +132,13 @@ $(eval $(call gb_Library_add_defs,vclplug_gen,\
endif
endif
+$(eval $(call gb_Library_add_defs,vclplug_gen,\
+ $(if $(VALGRIND_CFLAGS), \
+ $(VALGRIND_CFLAGS) \
+ -DHAVE_MEMCHECK_H=1 \
+ ) \
+))
+
## handle Xinerama
ifneq ($(USE_XINERAMA),NO)
ifneq ($(OS),SOLARIS)
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index b8b9f42..d48cf98 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -53,6 +53,10 @@
#include <unx/salinst.h>
#include <unx/x11/xlimits.hxx>
+#if defined(HAVE_MEMCHECK_H)
+#include <memcheck.h>
+#endif
+
// -----------
// - Defines -
// -----------
@@ -113,6 +117,21 @@ void X11SalBitmap::ImplRemovedFromCache()
delete mpDDB, mpDDB = NULL;
}
+#if defined(HAVE_MEMCHECK_H)
+void blankExtraSpace(BitmapBuffer* pDIB)
+{
+ size_t nExtraSpaceInScanLine = pDIB->mnScanlineSize - pDIB->mnWidth * pDIB->mnBitCount / 8;
+ if (nExtraSpaceInScanLine)
+ {
+ for (long i = 0; i < pDIB->mnHeight; ++i)
+ {
+ sal_uInt8 *pRow = pDIB->mpBits + (i * pDIB->mnScanlineSize);
+ memset(pRow + (pDIB->mnScanlineSize - nExtraSpaceInScanLine), 0, nExtraSpaceInScanLine);
+ }
+ }
+}
+#endif
+
// -----------------------------------------------------------------------------
BitmapBuffer* X11SalBitmap::ImplCreateDIB(
@@ -186,6 +205,10 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
try
{
pDIB->mpBits = new sal_uInt8[ pDIB->mnScanlineSize * pDIB->mnHeight ];
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(pDIB);
+#endif
}
catch (const std::bad_alloc&)
{
@@ -530,6 +553,10 @@ XImage* X11SalBitmap::ImplCreateXImage(
if( pDstBuf && pDstBuf->mpBits )
{
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(pDstBuf);
+#endif
// set data in buffer as data member in pImage
pImage->data = (char*) pDstBuf->mpBits;
@@ -704,6 +731,10 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
try
{
mpDIB->mpBits = new sal_uInt8[ mpDIB->mnScanlineSize * mpDIB->mnHeight ];
+#if defined(HAVE_MEMCHECK_H)
+ if (RUNNING_ON_VALGRIND)
+ blankExtraSpace(mpDIB);
+#endif
}
catch (const std::bad_alloc&)
{
commit c6a56e0b7f36b247c6808e3c6640c47599c5b56e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sat May 5 22:56:44 2012 +0100
catch by const ref
Change-Id: I20da7ac6dddcc1905b3419df37dd19f162cd8998
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 013bdd6..b8b9f42 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -137,7 +137,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
{
pDIB = new BitmapBuffer;
}
- catch( std::bad_alloc& )
+ catch (const std::bad_alloc&)
{
pDIB = NULL;
}
@@ -187,7 +187,7 @@ BitmapBuffer* X11SalBitmap::ImplCreateDIB(
{
pDIB->mpBits = new sal_uInt8[ pDIB->mnScanlineSize * pDIB->mnHeight ];
}
- catch(std::bad_alloc&)
+ catch (const std::bad_alloc&)
{
delete pDIB;
pDIB = NULL;
@@ -705,7 +705,7 @@ bool X11SalBitmap::Create( const SalBitmap& rSSalBmp )
{
mpDIB->mpBits = new sal_uInt8[ mpDIB->mnScanlineSize * mpDIB->mnHeight ];
}
- catch( std::bad_alloc& )
+ catch (const std::bad_alloc&)
{
delete mpDIB;
mpDIB = NULL;
More information about the Libreoffice-commits
mailing list