Skip to content

Commit 8616cec

Browse files
committed
improved pointer handling
1 parent 6899590 commit 8616cec

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

source/pdal/pdalc_pipeline.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern "C"
5959

6060
PDALPipelinePtr PDALCreatePipeline(const char* json)
6161
{
62-
Pipeline* pipeline = new Pipeline();
62+
std::unique_ptr<Pipeline> pipeline = std::make_unique<Pipeline>();
6363
if (json && std::strlen(json) > 0)
6464
{
6565
try
@@ -75,7 +75,6 @@ extern "C"
7575
catch (const std::exception &e)
7676
{
7777
printf("Could not create pipeline: %s\n%s\n", e.what(), json);
78-
delete pipeline;
7978
return nullptr;
8079
}
8180

@@ -86,11 +85,10 @@ extern "C"
8685
catch (const std::exception &e)
8786
{
8887
printf("Error while validating pipeline: %s\n%s\n", e.what(), json);
89-
delete pipeline;
9088
return nullptr;
9189
}
9290

93-
return pipeline;
91+
return pipeline.release();
9492
}
9593
return nullptr;
9694
}

0 commit comments

Comments
 (0)