Skip to content

Commit 3690451

Browse files
authored
Fix undefined malloc.
1 parent 8c51fb1 commit 3690451

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

YSI_Coding/y_malloc/y_malloc_heapalloc.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Optional plugins:
7676
#define YSI_DEFAULT_MALLOC (256)
7777
#endif
7878

79+
forward Alloc:Malloc_Allocate(size, const bool:clear = false);
80+
7981
/*-------------------------------------------------------------------------*//**
8082
* <remarks>
8183
* Finds all "BOUNDS 0" OpCodes in the AMX and rewrites them to "NOP NOP". The
@@ -179,7 +181,10 @@ public OnCodeInit()
179181
@emit JUMP addr + offset // Continue with code.
180182
}
181183
while ((idx = AMX_GetPublicEntry(idx, entry)));
182-
malloc(YSI_DEFAULT_MALLOC);
184+
// Allocate memory for callback parameters to use. They use some of the heap when passing
185+
// strings etc, so save some space at the bottom of the heap for them to use. This just leaks
186+
// memory from the allocation system, and allows it to be safely clobbered by those calls.
187+
Malloc_Allocate(YSI_DEFAULT_MALLOC);
183188
P:6("Malloc_OnCodeInit done");
184189
return 1;
185190
}

0 commit comments

Comments
 (0)