Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2190f8c

Browse files
committed
Added a class MallocHeapOutputBufferType for types that are passed
as &buffer, &size and allocated by the called function.
1 parent a2534c8 commit 2190f8c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Tools/bgen/bgen/bgenHeapBuffer.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,32 @@ class VarVarHeapOutputBufferType(VarHeapOutputBufferType):
111111

112112
def passOutput(self, name):
113113
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
114+
115+
class MallocHeapOutputBufferType(HeapOutputBufferType):
116+
"""Output buffer allocated by the called function -- passed as (&buffer, &size).
117+
118+
Instantiate without parameters.
119+
Call from Python without parameters.
120+
"""
121+
122+
def getargsCheck(self, name):
123+
Output("%s__out__ = NULL;", name)
124+
125+
def getAuxDeclarations(self, name):
126+
return []
127+
128+
def passOutput(self, name):
129+
return "&%s__out__, &%s__len__" % (name, name)
130+
131+
def getargsFormat(self):
132+
return ""
133+
134+
def getargsArgs(self, name):
135+
return None
136+
137+
def mkvalueFormat(self):
138+
return "z#"
139+
140+
def cleanup(self, name):
141+
Output("if( %s__out__ ) free(%s__out__);", name, name)
142+

0 commit comments

Comments
 (0)