Skip to content

Commit

Permalink
Added a class MallocHeapOutputBufferType for types that are passed
Browse files Browse the repository at this point in the history
as &buffer, &size and allocated by the called function.
  • Loading branch information
jackjansen committed Sep 20, 2005
1 parent a2534c8 commit 2190f8c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Tools/bgen/bgen/bgenHeapBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2190f8c

Please sign in to comment.