Skip to content

Commit cee5a94

Browse files
committed
Free array from the heap upon exit
Uses new name when freeing array of strings
1 parent 58b8dce commit cee5a94

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

arch/zx48k/translator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,10 +1680,10 @@ def visit_FUNCTION(self, node):
16801680
self.emit('pload%s' % self.TSUFFIX(gl.PTR_TYPE), t2,
16811681
'%i' % -(local_var.offset - self.TYPE(gl.PTR_TYPE).size))
16821682
self.emit('fparam' + self.TSUFFIX(gl.PTR_TYPE), t2)
1683-
self.emit('call', '__ARRAY_FREE', 0)
1684-
self.REQUIRES.add('arrayfree.asm')
1683+
self.emit('call', '__ARRAYSTR_FREE_MEM', 0) # frees all the strings and the array itself
1684+
self.REQUIRES.add('arraystrfree.asm')
16851685

1686-
if local_var.class_ == CLASS.array and \
1686+
if local_var.class_ == CLASS.array and local_var.type_ != self.TYPE(TYPE.string) and \
16871687
(scope == SCOPE.local or (scope == SCOPE.parameter and not local_var.byref)):
16881688
if not preserve_hl:
16891689
preserve_hl = True
@@ -1699,6 +1699,7 @@ def visit_FUNCTION(self, node):
16991699

17001700
self.emit('fparam' + self.TSUFFIX(gl.PTR_TYPE), t2)
17011701
self.emit('call', '__MEM_FREE', 0)
1702+
self.REQUIRES.add('free.asm')
17021703

17031704
if preserve_hl:
17041705
self.emit('exchg')

0 commit comments

Comments
 (0)