Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3752,6 +3752,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
declared=0;
} /* if */
if ((lastst!=tRETURN) && (lastst!=tGOTO)){
destructsymbols(&loctab,0);
ldconst(0,sPRI);
ffret(strcmp(sym->name,uENTRYFUNC)!=0);
if ((sym->usage & uRETVALUE)!=0 && (sym->flags & flagNAKED)==0) {
Expand Down Expand Up @@ -4844,7 +4845,7 @@ static cell calc_array_datasize(symbol *sym, cell *offset)
if (offset!=NULL)
*offset=length*(*offset+sizeof(cell));
if (sublength>0)
length*=length*sublength;
length*=sublength;
else
length=0;
} else {
Expand All @@ -4860,7 +4861,7 @@ static void destructsymbols(symbol *root,int level)
int savepri=FALSE;
symbol *sym=root->next;
while (sym!=NULL && sym->compound>=level) {
if (sym->ident==iVARIABLE || sym->ident==iARRAY) {
if ((sym->ident==iVARIABLE || sym->ident==iARRAY) && !(sym->vclass==sSTATIC && sym->fnumber==-1)) {
char symbolname[16];
symbol *opsym;
cell elements;
Expand All @@ -4874,6 +4875,15 @@ static void destructsymbols(symbol *root,int level)
} /* if */
/* if the variable is an array, get the number of elements */
if (sym->ident==iARRAY) {
/* according to the PAWN Implementer Guide, the destructor
* should be triggered for the data of the array only; hence
* if the array is a part of a larger array, it must be ignored
* as it's parent would(or has already) trigger(ed) the destructor
*/
if (sym->parent!=NULL) {
sym=sym->next;
continue;
} /* if */
elements=calc_array_datasize(sym,&offset);
/* "elements" can be zero when the variable is declared like
* new mytag: myvar[2][] = { {1, 2}, {3, 4} }
Expand Down