]> granicus.if.org Git - python/commitdiff
Added a class MallocHeapOutputBufferType for types that are passed
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 20 Sep 2005 21:11:19 +0000 (21:11 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 20 Sep 2005 21:11:19 +0000 (21:11 +0000)
as &buffer, &size and allocated by the called function.

Tools/bgen/bgen/bgenHeapBuffer.py

index 002a2606f6e4a682a23da4ef5e8d66ef0726ea9b..d677f291848c79384a63aeb15cc7bd28c4ca9d7c 100644 (file)
@@ -111,3 +111,32 @@ class VarVarHeapOutputBufferType(VarHeapOutputBufferType):
 
     def passOutput(self, name):
         return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
+        
+class MallocHeapOutputBufferType(HeapOutputBufferType):
+    """Output buffer allocated by the called function -- passed as (&buffer, &size).
+    
+    Instantiate without parameters.
+    Call from Python without parameters.
+    """
+
+    def getargsCheck(self, name):
+        Output("%s__out__ = NULL;", name)
+
+    def getAuxDeclarations(self, name):
+        return []
+        
+    def passOutput(self, name):
+        return "&%s__out__, &%s__len__" % (name, name)
+
+    def getargsFormat(self):
+        return ""
+
+    def getargsArgs(self, name):
+        return None
+        
+    def mkvalueFormat(self):
+        return "z#"
+        
+    def cleanup(self, name):
+        Output("if( %s__out__ ) free(%s__out__);", name, name)
+