@@ -74,71 +74,88 @@ namespace pdal
7474
7575 size_t PDALGetPipelineAsString (PDALPipelinePtr pipeline, char *buffer, size_t size)
7676 {
77- Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
78- pdal::PipelineExecutor *executor = ptr->get ();
7977 size_t result = 0 ;
80- buffer[0 ] = ' \0 ' ;
81- buffer[size - 1 ] = ' \0 ' ;
8278
83- if (executor )
79+ if (pipeline && buffer && size > 0 )
8480 {
85- std::string s = executor->getPipeline ();
86- std::strncpy (buffer, s.c_str (), size - 1 );
87- result = std::min (s.length (), size);
81+ Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
82+ pdal::PipelineExecutor *executor = ptr->get ();
83+ buffer[0 ] = ' \0 ' ;
84+ buffer[size - 1 ] = ' \0 ' ;
85+
86+ if (executor)
87+ {
88+ std::string s = executor->getPipeline ();
89+ std::strncpy (buffer, s.c_str (), size - 1 );
90+ result = std::min (s.length (), size);
91+ }
92+
8893 }
8994
9095 return result;
9196 }
9297
9398 size_t PDALGetPipelineMetadata (PDALPipelinePtr pipeline, char *metadata, size_t size)
9499 {
95- Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
96- pdal::PipelineExecutor *executor = ptr->get ();
97100 size_t result = 0 ;
98- metadata[0 ] = ' \0 ' ;
99- metadata[size - 1 ] = ' \0 ' ;
100101
101- if (executor )
102+ if (pipeline && metadata && size > 0 )
102103 {
103- std::string s = executor->getMetadata ();
104- std::strncpy (metadata, s.c_str (), size);
105- result = std::min (s.length (), size);
104+ Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
105+ pdal::PipelineExecutor *executor = ptr->get ();
106+ metadata[0 ] = ' \0 ' ;
107+ metadata[size - 1 ] = ' \0 ' ;
108+
109+ if (executor)
110+ {
111+ std::string s = executor->getMetadata ();
112+ std::strncpy (metadata, s.c_str (), size);
113+ result = std::min (s.length (), size);
114+ }
106115 }
107116
108117 return result;
109118 }
110119
111120 size_t PDALGetPipelineSchema (PDALPipelinePtr pipeline, char *schema, size_t size)
112121 {
113- Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
114- pdal::PipelineExecutor *executor = ptr->get ();
115122 size_t result = 0 ;
116- schema[0 ] = ' \0 ' ;
117- schema[size - 1 ] = ' \0 ' ;
118123
119- if (executor )
124+ if (pipeline && schema && size > 0 )
120125 {
121- std::string s = executor->getSchema ();
122- std::strncpy (schema, s.c_str (), size);
123- result = std::min (s.length (), size);
126+ Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
127+ pdal::PipelineExecutor *executor = ptr->get ();
128+ schema[0 ] = ' \0 ' ;
129+ schema[size - 1 ] = ' \0 ' ;
130+
131+ if (executor)
132+ {
133+ std::string s = executor->getSchema ();
134+ std::strncpy (schema, s.c_str (), size);
135+ result = std::min (s.length (), size);
136+ }
124137 }
125138
126139 return result;
127140 }
128141
129142 size_t PDALGetPipelineLog (PDALPipelinePtr pipeline, char *log, size_t size)
130143 {
131- Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
132- pdal::PipelineExecutor *executor = ptr->get ();
133144 size_t result = 0 ;
134- log[0 ] = ' \0 ' ;
135- log[size - 1 ] = ' \0 ' ;
136145
137- if (executor )
146+ if (pipeline && log && size > 0 )
138147 {
139- std::string s = executor->getLog ();
140- std::strncpy (log, s.c_str (), size);
141- result = std::min (s.length (), size);
148+ Pipeline *ptr = reinterpret_cast <Pipeline *>(pipeline);
149+ pdal::PipelineExecutor *executor = ptr->get ();
150+ log[0 ] = ' \0 ' ;
151+ log[size - 1 ] = ' \0 ' ;
152+
153+ if (executor)
154+ {
155+ std::string s = executor->getLog ();
156+ std::strncpy (log, s.c_str (), size);
157+ result = std::min (s.length (), size);
158+ }
142159 }
143160
144161 return result;
0 commit comments