[Lldb-commits] [PATCH] D18459: Fix FILE * leak in Python API

Francis Ricci via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 25 13:12:25 PDT 2016


fjricci updated this revision to Diff 51678.
fjricci added a comment.

Extend SBCommandReturnObject API to allow for taking file ownership


http://reviews.llvm.org/D18459

Files:
  include/lldb/API/SBCommandReturnObject.h
  scripts/interface/SBCommandReturnObject.i
  source/API/SBCommandReturnObject.cpp

Index: source/API/SBCommandReturnObject.cpp
===================================================================
--- source/API/SBCommandReturnObject.cpp
+++ source/API/SBCommandReturnObject.cpp
@@ -270,6 +270,20 @@
 }
 
 void
+SBCommandReturnObject::SetImmediateOutputFileWithOwnership(FILE *fh)
+{
+    if (m_opaque_ap)
+        m_opaque_ap->SetImmediateOutputFile(fh, true);
+}
+
+void
+SBCommandReturnObject::SetImmediateErrorFileWithOwnership(FILE *fh)
+{
+    if (m_opaque_ap)
+        m_opaque_ap->SetImmediateErrorFile(fh, true);
+}
+
+void
 SBCommandReturnObject::PutCString(const char* string, int len)
 {
     if (m_opaque_ap)
Index: scripts/interface/SBCommandReturnObject.i
===================================================================
--- scripts/interface/SBCommandReturnObject.i
+++ scripts/interface/SBCommandReturnObject.i
@@ -16,6 +16,7 @@
 
 See SBCommandInterpreter for example usage of SBCommandReturnObject."
 ) SBCommandReturnObject;
+
 class SBCommandReturnObject
 {
 public:
@@ -84,11 +85,14 @@
     bool
     GetDescription (lldb::SBStream &description);
     
+    %rename(SetImmediateOutputFile) SetImmediateOutputFileWithOwnership;
+    %rename(SetImmediateErrorFile) SetImmediateErrorFileWithOwnership;
+
     void
-    SetImmediateOutputFile (FILE *fh);
-    
+    SetImmediateOutputFileWithOwnership (FILE *fh);
+
     void
-    SetImmediateErrorFile (FILE *fh);
+    SetImmediateErrorFileWithOwnership (FILE *fh);
 
 	void
 	PutCString(const char* string, int len);
Index: include/lldb/API/SBCommandReturnObject.h
===================================================================
--- include/lldb/API/SBCommandReturnObject.h
+++ include/lldb/API/SBCommandReturnObject.h
@@ -91,6 +91,12 @@
     SetImmediateErrorFile (FILE *fh);
     
     void
+    SetImmediateOutputFileWithOwnership(FILE* file);
+    
+    void
+    SetImmediateErrorFileWithOwnership(FILE* file);
+    
+    void
     PutCString(const char* string, int len = -1);
     
     size_t


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18459.51678.patch
Type: text/x-patch
Size: 1993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160325/916a9c28/attachment.bin>


More information about the lldb-commits mailing list