From da71443f77f499468d48b3f404eb6c59851eef8a Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 6 Feb 2012 16:06:17 +0100 Subject: (cppcheck and janitorial tasks:) C-style casting to C++-style casting (bzr r10946) --- src/sp-switch.h | 2 +- src/sp-use-reference.h | 2 +- src/trace/siox.cpp | 18 ++++++++++-------- src/ui/dialog/debug.cpp | 2 +- src/ui/dialog/dialog.cpp | 10 +++++----- src/ui/dialog/messages.cpp | 5 ++--- src/ui/dialog/tile.cpp | 6 ++---- 7 files changed, 22 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/sp-switch.h b/src/sp-switch.h index 8eafe6e7b..c2c98e3b3 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -55,7 +55,7 @@ private: }; struct SPSwitch : public SPGroup { - void resetChildEvaluated() { ((CSwitch *)group)->_reevaluate(); } + void resetChildEvaluated() { (static_cast(group))->_reevaluate(); } }; struct SPSwitchClass : public SPGroupClass { diff --git a/src/sp-use-reference.h b/src/sp-use-reference.h index bbedb9875..f40dbb6e5 100644 --- a/src/sp-use-reference.h +++ b/src/sp-use-reference.h @@ -28,7 +28,7 @@ public: SPUseReference(SPObject *owner) : URIReference(owner) {} SPItem *getObject() const { - return (SPItem *)URIReference::getObject(); + return static_cast(URIReference::getObject()); } protected: diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 4c6cf1eac..9376fad66 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -1330,29 +1330,31 @@ bool Siox::colorSignature(const std::vector &inputVec, if (length < 1) // no error. just don't do anything return true; - CieLab *input = (CieLab *) malloc(length * sizeof(CieLab)); + CieLab *input = new CieLab [length]; if (!input) - { + { error("Could not allocate buffer for signature"); return false; - } + } for (unsigned int i=0 ; i < length ; i++) + { input[i] = inputVec[i]; + } unsigned int stage1length = 0; - colorSignatureStage1(input, 0, length, 0, - &stage1length, dims); + colorSignatureStage1(input, 0, length, 0, &stage1length, dims); unsigned int stage2length = 0; - colorSignatureStage2(input, 0, stage1length, 0, - &stage2length, length * 0.001, dims); + colorSignatureStage2(input, 0, stage1length, 0, &stage2length, length * 0.001, dims); result.clear(); for (unsigned int i=0 ; i < stage2length ; i++) + { result.push_back(input[i]); + } - free(input); + delete[] input; return true; } diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index 426cd5d99..8ffbd5c52 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -167,7 +167,7 @@ void dialogLoggingFunction(const gchar */*log_domain*/, const gchar *messageText, gpointer user_data) { - DebugDialogImpl *dlg = (DebugDialogImpl *)user_data; + DebugDialogImpl *dlg = static_cast(user_data); dlg->message(messageText); } diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 0a7359155..43c9493b3 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -41,20 +41,20 @@ namespace Dialog { void sp_retransientize(Inkscape::Application */*inkscape*/, SPDesktop *desktop, gpointer dlgPtr) { - Dialog *dlg = (Dialog *)dlgPtr; + Dialog *dlg = static_cast(dlgPtr); dlg->onDesktopActivated (desktop); } gboolean sp_retransientize_again(gpointer dlgPtr) { - Dialog *dlg = (Dialog *)dlgPtr; + Dialog *dlg = static_cast(dlgPtr); dlg->retransientize_suppress = false; return FALSE; // so that it is only called once } void sp_dialog_shutdown(GtkObject */*object*/, gpointer dlgPtr) { - Dialog *dlg = (Dialog *)dlgPtr; + Dialog *dlg = static_cast(dlgPtr); dlg->onShutdown(); } @@ -63,7 +63,7 @@ void hideCallback(GtkObject */*object*/, gpointer dlgPtr) { g_return_if_fail( dlgPtr != NULL ); - Dialog *dlg = (Dialog *)dlgPtr; + Dialog *dlg = static_cast(dlgPtr); dlg->onHideF12(); } @@ -71,7 +71,7 @@ void unhideCallback(GtkObject */*object*/, gpointer dlgPtr) { g_return_if_fail( dlgPtr != NULL ); - Dialog *dlg = (Dialog *)dlgPtr; + Dialog *dlg = static_cast(dlgPtr); dlg->onShowF12(); } diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp index 52bd58492..df02215fe 100644 --- a/src/ui/dialog/messages.cpp +++ b/src/ui/dialog/messages.cpp @@ -124,9 +124,8 @@ static void dialogLoggingCallback(const gchar */*log_domain*/, const gchar *messageText, gpointer user_data) { - Messages *dlg = (Messages *)user_data; - - dlg->message((char *)messageText); + Messages *dlg = static_cast(user_data); + dlg->message(const_cast(messageText)); } diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 50b63f701..8ca0ba348 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -41,8 +41,7 @@ * 0 *elem1 == *elem2 * >0 *elem1 goes after *elem2 */ -int -sp_compare_x_position(SPItem *first, SPItem *second) +int sp_compare_x_position(SPItem *first, SPItem *second) { using Geom::X; using Geom::Y; @@ -603,8 +602,7 @@ void TileDialog::updateSelection() static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, TileDialog *dlg) { - TileDialog *tledlg = (TileDialog *) dlg; - tledlg->updateSelection(); + dlg->updateSelection(); } -- cgit v1.2.3