You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
8.8 KiB
263 lines
8.8 KiB
From d2c6003ca5b0116fc18505b4fd34b211484e41ca Mon Sep 17 00:00:00 2001 |
|
From: Sebastian Kraft <mail@sebastiankraft.net> |
|
Date: Sat, 19 Dec 2015 20:08:24 +0100 |
|
Subject: [PATCH 038/113] Only use proper C++ new and delete syntax for object |
|
creation in tests and lenstool |
|
|
|
--- |
|
apps/lenstool/lenstool.cpp | 16 ++++++++-------- |
|
tests/test_database.cpp | 4 ++-- |
|
tests/test_modifier.cpp | 8 +++++--- |
|
tests/test_modifier_color.cpp | 4 ++-- |
|
tests/test_modifier_coord_distortion.cpp | 4 ++-- |
|
tests/test_modifier_coord_geometry.cpp | 4 ++-- |
|
tests/test_modifier_coord_scale.cpp | 4 ++-- |
|
tests/test_modifier_subpix.cpp | 4 ++-- |
|
8 files changed, 25 insertions(+), 23 deletions(-) |
|
|
|
diff --git a/apps/lenstool/lenstool.cpp b/apps/lenstool/lenstool.cpp |
|
index 0aab056..399195e 100644 |
|
--- a/apps/lenstool/lenstool.cpp |
|
+++ b/apps/lenstool/lenstool.cpp |
|
@@ -360,7 +360,7 @@ int main (int argc, char **argv) |
|
lfDatabase *ldb = new lfDatabase (); |
|
|
|
if (ldb->Load () != LF_NO_ERROR) { |
|
- ldb->Destroy(); |
|
+ delete ldb; |
|
g_print ("\rERROR: Database could not be loaded\n"); |
|
return -1; |
|
} |
|
@@ -410,7 +410,7 @@ int main (int argc, char **argv) |
|
|
|
// nothing to process, so lets quit here |
|
if (!opts.Input) { |
|
- ldb->Destroy(); |
|
+ delete ldb; |
|
return 0; |
|
} |
|
|
|
@@ -441,22 +441,22 @@ int main (int argc, char **argv) |
|
if (!img->Open (opts.Input)) { |
|
g_print ("\rERROR: failed to open file `%s'\n", opts.Input); |
|
delete img; |
|
- ldb->Destroy(); |
|
+ delete ldb; |
|
return -1; |
|
} |
|
if (!img->LoadPNG ()) { |
|
g_print ("\rERROR: failed to parse PNG data from file `%s'\n", opts.Input); |
|
delete img; |
|
- ldb->Destroy(); |
|
+ delete ldb; |
|
return -1; |
|
} |
|
g_print ("done.\n~ Image size [%ux%u].\n", img->width, img->height); |
|
|
|
- lfModifier *mod = lfModifier::Create (lens, opts.Crop, img->width, img->height); |
|
+ lfModifier *mod = new lfModifier (lens, opts.Crop, img->width, img->height); |
|
if (!mod) { |
|
g_print ("\rWarning: failed to create modifier\n"); |
|
delete img; |
|
- ldb->Destroy(); |
|
+ delete ldb; |
|
return -1; |
|
} |
|
int modflags = mod->Initialize ( |
|
@@ -491,13 +491,13 @@ int main (int argc, char **argv) |
|
clock_t et = clock (); |
|
g_print ("done (%.3g secs)\n", double (et - st) / CLOCKS_PER_SEC); |
|
|
|
- mod->Destroy (); |
|
+ delete mod; |
|
|
|
g_print ("~ Save output as `%s'...", opts.Output); |
|
bool ok = img->SavePNG (opts.Output); |
|
|
|
delete img; |
|
- ldb->Destroy (); |
|
+ delete ldb; |
|
|
|
if (ok) { |
|
g_print (" done\n"); |
|
diff --git a/tests/test_database.cpp b/tests/test_database.cpp |
|
index d64984a..45dc38f 100644 |
|
--- a/tests/test_database.cpp |
|
+++ b/tests/test_database.cpp |
|
@@ -9,14 +9,14 @@ typedef struct { |
|
|
|
void db_setup(lfFixture *lfFix, gconstpointer data) |
|
{ |
|
- lfFix->db = lf_db_new (); |
|
+ lfFix->db = new lfDatabase (); |
|
lfFix->db->Load(); |
|
} |
|
|
|
|
|
void db_teardown(lfFixture *lfFix, gconstpointer data) |
|
{ |
|
- lfFix->db->Destroy(); |
|
+ delete lfFix->db; |
|
} |
|
|
|
|
|
diff --git a/tests/test_modifier.cpp b/tests/test_modifier.cpp |
|
index 3d091a4..f794638 100644 |
|
--- a/tests/test_modifier.cpp |
|
+++ b/tests/test_modifier.cpp |
|
@@ -31,7 +31,6 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
|
|
void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
{ |
|
- lfFix->mod->Destroy(); |
|
delete lfFix->lens; |
|
} |
|
|
|
@@ -55,7 +54,7 @@ void test_mod_projection_center(lfFixture* lfFix, gconstpointer data) |
|
if(g_test_verbose()) |
|
g_print(" ~ Conversion from %s -> %s \n", geom_names[j], geom_names[i]); |
|
|
|
- lfFix->mod = lfModifier::Create (lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier (lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
lfFix->mod->Initialize ( |
|
lfFix->lens, LF_PF_U8, 12.0f, |
|
6.7f, 2.0f, 1.0f, geom_types[i], |
|
@@ -68,6 +67,8 @@ void test_mod_projection_center(lfFixture* lfFix, gconstpointer data) |
|
g_assert_cmpfloat(in[0],==,res[0]); |
|
g_assert_cmpfloat(in[1],==,res[1]); |
|
} |
|
+ |
|
+ delete lfFix->mod; |
|
i++; |
|
} |
|
j++; |
|
@@ -94,7 +95,7 @@ void test_mod_projection_borders(lfFixture* lfFix, gconstpointer data) |
|
if(g_test_verbose()) |
|
g_print(" ~ Conversion from %s -> %s \n", geom_names[j], geom_names[i]); |
|
|
|
- lfFix->mod = lfModifier::Create (lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier (lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
lfFix->mod->Initialize ( |
|
lfFix->lens, LF_PF_U8, 12.0f, |
|
6.7f, 2.0f, 1.0f, geom_types[i], |
|
@@ -115,6 +116,7 @@ void test_mod_projection_borders(lfFixture* lfFix, gconstpointer data) |
|
g_assert_false(isnan(res[1])); |
|
} |
|
|
|
+ delete lfFix->mod; |
|
i++; |
|
} |
|
j++; |
|
diff --git a/tests/test_modifier_color.cpp b/tests/test_modifier_color.cpp |
|
index 4c5e2dc..6327232 100644 |
|
--- a/tests/test_modifier_color.cpp |
|
+++ b/tests/test_modifier_color.cpp |
|
@@ -107,7 +107,7 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
lfFix->img_height = 300; |
|
lfFix->img_width = 300; |
|
|
|
- lfFix->mod = lfModifier::Create(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
|
|
lfFix->mod->Initialize( |
|
lfFix->lens, cTypeToLfPixelFormat<T>(), |
|
@@ -134,7 +134,7 @@ void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
else |
|
lf_free_align(lfFix->image); |
|
|
|
- lfFix->mod->Destroy(); |
|
+ delete lfFix->mod; |
|
delete lfFix->lens; |
|
} |
|
|
|
diff --git a/tests/test_modifier_coord_distortion.cpp b/tests/test_modifier_coord_distortion.cpp |
|
index 6fd6773..f463350 100644 |
|
--- a/tests/test_modifier_coord_distortion.cpp |
|
+++ b/tests/test_modifier_coord_distortion.cpp |
|
@@ -51,7 +51,7 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
lfFix->img_height = 300; |
|
lfFix->img_width = 300; |
|
|
|
- lfFix->mod = lfModifier::Create(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
|
|
lfFix->mod->Initialize( |
|
lfFix->lens, LF_PF_F32, |
|
@@ -76,7 +76,7 @@ void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
else |
|
lf_free_align(lfFix->coordBuff); |
|
|
|
- lfFix->mod->Destroy(); |
|
+ delete lfFix->mod; |
|
delete lfFix->lens; |
|
} |
|
|
|
diff --git a/tests/test_modifier_coord_geometry.cpp b/tests/test_modifier_coord_geometry.cpp |
|
index 6805b7d..d626ba8 100644 |
|
--- a/tests/test_modifier_coord_geometry.cpp |
|
+++ b/tests/test_modifier_coord_geometry.cpp |
|
@@ -51,7 +51,7 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
lfFix->img_height = 300; |
|
lfFix->img_width = 300; |
|
|
|
- lfFix->mod = lfModifier::Create(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
|
|
lfFix->mod->Initialize( |
|
lfFix->lens, LF_PF_F32, |
|
@@ -76,7 +76,7 @@ void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
else |
|
lf_free_align(lfFix->coordBuff); |
|
|
|
- lfFix->mod->Destroy(); |
|
+ delete lfFix->mod; |
|
delete lfFix->lens; |
|
} |
|
|
|
diff --git a/tests/test_modifier_coord_scale.cpp b/tests/test_modifier_coord_scale.cpp |
|
index c155ff8..84a4286 100644 |
|
--- a/tests/test_modifier_coord_scale.cpp |
|
+++ b/tests/test_modifier_coord_scale.cpp |
|
@@ -48,7 +48,7 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
lfFix->img_height = 300; |
|
lfFix->img_width = 300; |
|
|
|
- lfFix->mod = lfModifier::Create(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
|
|
lfFix->mod->Initialize( |
|
lfFix->lens, LF_PF_F32, |
|
@@ -73,7 +73,7 @@ void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
else |
|
lf_free_align(lfFix->coordBuff); |
|
|
|
- lfFix->mod->Destroy(); |
|
+ delete lfFix->mod; |
|
delete lfFix->lens; |
|
} |
|
|
|
diff --git a/tests/test_modifier_subpix.cpp b/tests/test_modifier_subpix.cpp |
|
index d04f36d..fa29cf6 100644 |
|
--- a/tests/test_modifier_subpix.cpp |
|
+++ b/tests/test_modifier_subpix.cpp |
|
@@ -51,7 +51,7 @@ void mod_setup(lfFixture *lfFix, gconstpointer data) |
|
lfFix->img_height = 300; |
|
lfFix->img_width = 300; |
|
|
|
- lfFix->mod = lfModifier::Create(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
+ lfFix->mod = new lfModifier(lfFix->lens, 1.0f, lfFix->img_width, lfFix->img_height); |
|
|
|
lfFix->mod->Initialize( |
|
lfFix->lens, LF_PF_F32, |
|
@@ -76,7 +76,7 @@ void mod_teardown(lfFixture *lfFix, gconstpointer data) |
|
else |
|
lf_free_align(lfFix->coordBuff); |
|
|
|
- lfFix->mod->Destroy(); |
|
+ delete lfFix->mod; |
|
delete lfFix->lens; |
|
} |
|
|
|
-- |
|
2.7.4 |
|
|
|
|