File tree 2 files changed +15
-7
lines changed
examples/chip-tool/commands
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -230,13 +230,7 @@ class CustomArgumentParser
230
230
class CustomArgument
231
231
{
232
232
public:
233
- ~CustomArgument ()
234
- {
235
- if (mData != nullptr )
236
- {
237
- chip::Platform::MemoryFree (mData );
238
- }
239
- }
233
+ ~CustomArgument () { Reset (); }
240
234
241
235
CHIP_ERROR Parse (const char * label, const char * json)
242
236
{
@@ -286,6 +280,15 @@ class CustomArgument
286
280
return writer.CopyElement (tag, reader);
287
281
}
288
282
283
+ void Reset ()
284
+ {
285
+ if (mData != nullptr )
286
+ {
287
+ chip::Platform::MemoryFree (mData );
288
+ mData = nullptr ;
289
+ }
290
+ }
291
+
289
292
// We trust our consumers to do the encoding of our data correctly, so don't
290
293
// need to know whether we are being encoded for a write.
291
294
static constexpr bool kIsFabricScoped = false ;
Original file line number Diff line number Diff line change @@ -1069,6 +1069,11 @@ void Command::ResetArguments()
1069
1069
auto vectorArgument = static_cast <std::vector<uint32_t > *>(arg.value );
1070
1070
vectorArgument->clear ();
1071
1071
}
1072
+ else if (type == ArgumentType::Custom)
1073
+ {
1074
+ auto argument = static_cast <CustomArgument *>(arg.value );
1075
+ argument->Reset ();
1076
+ }
1072
1077
else if (type == ArgumentType::VectorCustom)
1073
1078
{
1074
1079
auto vectorArgument = static_cast <std::vector<CustomArgument *> *>(arg.value );
You can’t perform that action at this time.
0 commit comments