@@ -52,14 +52,9 @@ lldb_private::LLDBSwigPythonBreakpointCallbackFunction
52
52
53
53
auto result = [&] () -> Expected<PythonObject> {
54
54
// If the called function doesn't take extra_args, drop them here:
55
- if (max_positional_args < 4) {
55
+ if (max_positional_args < 4)
56
56
return pfunc.Call(frame_arg, bp_loc_arg, dict);
57
- } else {
58
- // FIXME: SBStructuredData leaked here
59
- lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
60
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(*args_value));
61
- return pfunc.Call(frame_arg, bp_loc_arg, args_arg, dict);
62
- }
57
+ return pfunc.Call(frame_arg, bp_loc_arg, ToSWIGWrapper(args_impl), dict);
63
58
} ();
64
59
65
60
if (!result)
@@ -289,11 +284,7 @@ lldb_private::LLDBSwigPythonCreateScriptedProcess
289
284
290
285
PythonObject result = {};
291
286
if (arg_info.get().max_positional_args == 2) {
292
- // FIXME: SBStructuredData leaked here
293
- PythonObject args_arg(
294
- PyRefType::Owned,
295
- SBTypeToSWIGWrapper(*new lldb::SBStructuredData(args_impl)));
296
- result = pfunc(target_arg, args_arg);
287
+ result = pfunc(target_arg, ToSWIGWrapper(args_impl));
297
288
} else {
298
289
error_string.assign("wrong number of arguments in __init__, should be 2 (not including self)");
299
290
Py_RETURN_NONE;
@@ -343,11 +334,7 @@ lldb_private::LLDBSwigPythonCreateScriptedThread
343
334
344
335
PythonObject result = {};
345
336
if (arg_info.get().max_positional_args == 2) {
346
- // FIXME: SBStructuredData leaked here
347
- PythonObject args_arg(
348
- PyRefType::Owned,
349
- SBTypeToSWIGWrapper(*new lldb::SBStructuredData(args_impl)));
350
- result = pfunc(ToSWIGWrapper(process_sp), args_arg);
337
+ result = pfunc(ToSWIGWrapper(process_sp), ToSWIGWrapper(args_impl));
351
338
} else {
352
339
error_string.assign("wrong number of arguments in __init__, should be 2 (not including self)");
353
340
Py_RETURN_NONE;
@@ -399,17 +386,15 @@ lldb_private::LLDBSwigPythonCreateScriptedThreadPlan
399
386
}
400
387
401
388
PythonObject result = {};
402
- // FIXME: SBStructuredData leaked here
403
- auto *args_sb = new lldb::SBStructuredData(args_impl);
389
+ auto args_sb = std::make_unique<lldb::SBStructuredData>(args_impl);
404
390
if (arg_info.get().max_positional_args == 2) {
405
391
if (args_sb->IsValid()) {
406
392
error_string.assign("args passed, but __init__ does not take an args dictionary");
407
393
Py_RETURN_NONE;
408
394
}
409
395
result = pfunc(tp_arg, dict);
410
396
} else if (arg_info.get().max_positional_args >= 3) {
411
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(*args_sb));
412
- result = pfunc(tp_arg, args_arg, dict);
397
+ result = pfunc(tp_arg, ToSWIGWrapper(std::move(args_sb)), dict);
413
398
} else {
414
399
error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)");
415
400
Py_RETURN_NONE;
@@ -486,11 +471,8 @@ void *lldb_private::LLDBSwigPythonCreateScriptedBreakpointResolver(
486
471
if (!pfunc.IsAllocated())
487
472
return nullptr;
488
473
489
- // FIXME: SBStructuredData leaked here
490
- lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
491
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(*args_value));
492
-
493
- PythonObject result = pfunc(ToSWIGWrapper(breakpoint_sp), args_arg, dict);
474
+ PythonObject result =
475
+ pfunc(ToSWIGWrapper(breakpoint_sp), ToSWIGWrapper(args_impl), dict);
494
476
// FIXME: At this point we should check that the class we found supports all the methods
495
477
// that we need.
496
478
@@ -591,11 +573,8 @@ lldb_private::LLDBSwigPythonCreateScriptedStopHook
591
573
return nullptr;
592
574
}
593
575
594
- // FIXME: SBStructuredData leaked here
595
- lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
596
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(*args_value));
597
-
598
- PythonObject result = pfunc(ToSWIGWrapper(target_sp), args_arg, dict);
576
+ PythonObject result =
577
+ pfunc(ToSWIGWrapper(target_sp), ToSWIGWrapper(args_impl), dict);
599
578
600
579
if (result.IsAllocated())
601
580
{
0 commit comments