Added a class MallocHeapOutputBufferType for types that are passed

as &buffer, &size and allocated by the called function.
This commit is contained in:
Jack Jansen 2005-09-20 21:11:19 +00:00
parent a2534c8618
commit 2190f8c47e
1 changed files with 29 additions and 0 deletions

View 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)