-
Notifications
You must be signed in to change notification settings - Fork 1
/
lensfun-0.3.2-Only-use-proper-C-new-and-delete-syntax-for-object-c.patch
263 lines (222 loc) · 8.77 KB
/
lensfun-0.3.2-Only-use-proper-C-new-and-delete-syntax-for-object-c.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
From d2c6003ca5b0116fc18505b4fd34b211484e41ca Mon Sep 17 00:00:00 2001
From: Sebastian Kraft <[email protected]>
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